Page 1 of 1

how to combine two images.

Posted: Sat Jul 12, 2003 1:19 pm
by macewan
Please excuse me if this post is done incorrectly. This is the php code I will be using to combine two images. Thought maybe someone else would like a copy. See this directory for an example use. The code listed below is referred to as test_02.php & test_02.txt in my testing directory.

Enjoy.

Code: Select all

<?php
$im = "copyright.png";
$out = "jpg"; 
$backgroundfile = "back.jpg";
$image_id = imageCreateFromPNG($im);
$im_X = ImageSX($image_id);
$im_Y = ImageSY($image_id);
$backgroundimage = imageCreateFromJPEG($backgroundfile);
imagecopy($backgroundimage, $image_id, 0, 0, 0, 0, $im_X, $im_Y);
Header( "Content-type: image/jpeg");
  ImageJPEG($backgroundimage);
ImageDestroy($backgroundimage);
ImageDestroy($image_id);
?>

Posted: Sat Jul 12, 2003 1:24 pm
by m3rajk
thanx! i actually was thinking of overwrighting a tag on a picture when storing it for the site i'm working on, but with this i can leave it as is and have a page place a tag on top on the fly.

probably less efficient but definitely something that will work.
:)

Posted: Sat Jul 12, 2003 1:39 pm
by macewan
=)