How to automatically position photo on a background

Asked

Viewed 31 times

0

i am with a problem, I need to know how to correctly and automatically position a photo in any background, for example I want this avatar (http://i.imgur.com/O7hn5tb.png) is positioned in the field that is AVATAR 180x180 (http://i.imgur.com/mvE3Llp.jpg).

But I need to make any 180x180 avatar fit in other images, for example this: http://i.imgur.com/mvKPozO.png

I tried this code but it doesn’t work, I believe it’s the coordinates that are incorrect, it’s just appearing in the background.

$newNome = md5(time()) . ".jpg";
$mainphoto = imagecreatefromjpeg("foto.jpg");
imagecopymerge($mainphoto, "fundo.jpg", 10, 10, 0, 0, 180, 180, 100);
header('Content-Type: image/jpg');
imagejpeg($mainphoto, $newNome, 50);
imagedestroy($mainphoto);
  • Already tried to invert the parameters of imagecopymerge, first the background then the avatar?

  • @fernandoandrade yes I tried but it doesn’t work.

  • I’ve done something like that only it was using the lib Wideimage

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.