0
I was able to set the fixed size for the image (500x500) now I wanted to know if you have to take this image already defined and put another one on top 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);
?>
So, I tried but gives that broken image icon, I do not know if I’m calling the right image in "imagejpeg(); I will post the code to facilitate...
– Bruno
This puts the code, additionally the broken image icon appears in the front or back image?
– Alan Rezende
No image appears when I add imagecopymerge()
– Bruno
@Bruno take a look at my answer, probably the problem is in
$_POST['img'];
which should be$_FILES['img']['tmp_name']
– Alan Rezende
I don’t think so, because the [$_POST['img]] comes from a link that the user type in the input text, being the jpg image, not uploading anything on the server...
– Bruno
This link is a relative link
/img/teste.jpg
or completehttp://teste.com/imagem.jpg
– Alan Rezende
Complete... I will edit the code(again) I made a form that overlaps the two image and after a resize to 500px maaas, I wanted to give the resize of 500px and then put the image over, so the image would be in the center, for example this flag that Facebook put up from France... you know? I’m trying to do in php for study...
– Bruno
Nothing yet....?
– Bruno
test
imagecopyresampled($image_p, $user, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
imagecopymerge($image_p, $mask, 0,0,0,0,500,500,50);
– Alan Rezende
It worked lol worth Alan :D
– Bruno