Jump to content

Creating Images


ShoeLace1291

Recommended Posts

I want to create an image using pre-existing image files.  I want to use more than one file, otherwise I would use the imagecreatefromjpg function.  What function should I use to create an image using a for statement to determine how many of each image is being displayed in the new image?

 

Link to comment
https://forums.phpfreaks.com/topic/246890-creating-images/
Share on other sites

this script will create an image from 5 different sources.

 


// Create image instances
$src = imagecreatefromjpeg('images/desert.jpg');
$src1 = imagecreatefromjpeg('images/koala.jpg');
$src2 = imagecreatefromjpeg('images/lighthouse.jpg');
$src3 = imagecreatefromjpeg('images/Penguins.jpg');
$src4 = imagecreatefromjpeg('images/jellyfish.jpg');
$dest = imagecreatetruecolor(500, 100);

// Copy
imagecopy($dest, $src, 0, 0, 500, 500, 100, 100);
imagecopy($dest, $src1, 100, 0, 500, 500, 100, 100);
imagecopy($dest, $src2, 200, 0, 500, 500, 100, 100);
imagecopy($dest, $src3, 300, 0, 500, 500, 100, 100);
imagecopy($dest, $src4, 400, 0, 500, 500, 100, 100);

// Output and free from memory
header('Content-Type: image/jpg');
imagejpeg($dest);

imagedestroy($dest);
imagedestroy($src);
imagedestroy($src1);
imagedestroy($src2);
imagedestroy($src3);
imagedestroy($src4);



Link to comment
https://forums.phpfreaks.com/topic/246890-creating-images/#findComment-1267934
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.