Can you use an imagecopyresampled and an imagecopymerge at the same time?

0

I was able to set the fixed size for the image (500x500) now I wanted to know if you have how to get this image already defined and put another with imagecopymerge?

<?php

$img = $_POST['img'];
$user = imagecreatefromjpeg($img);
$mask = imagecreatefromgif('imgs/logo.gif');
$width = 500;
$height = 500;
$image_p = imagecreatetruecolor($width, $height);
list($width_orig, $height_orig) = getimagesize($img);
$ratio_orig = $width_orig/$height_orig;
if ($width/$height > $ratio_orig) {
      $width = $height*$ratio_orig;
   } else {
      $height = $width/$ratio_orig;
   }
$imagem = imagecopymerge($user, $mask, 0,0,0,0,500,500,50);
imagecopyresampled($image_p, $user, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
header('Content-Type: image/png');
imagepng($image_p);
?>
    
asked by anonymous 17.11.2015 / 03:36

1 answer

1

Yes, it has.

Let's say you have this image of imagecopyresampled in variable $minhaImagem , you can use it $dst_im of imagecopymerge

imagecopymerge ( $minhaImagem , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h , int $pct )

Remember that to work with images you must use

$_FILES['img']['tmp_name']

Instead of

$_POST['img']

And your form must have the enctype="multipart/form-data" attribute

More information on php.net

    
17.11.2015 / 03:45