Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.