Jump to content

Is it possible to include a photo inside a PHP GD Graphic image?


algarve4me

Recommended Posts

I have been experimenting with php GD Graphics.

 

I have managed to create a new jpeg image and insert dynamic text from a mysql database into the image. I have now come up against a problem and I have been unable to find an answer on the internet.

 

Is it possible to create a new jpeg php gd image and then insert an existing jpeg photo into that image?

AndyB

 

Thank you for that reference. I wasn't aware that I could use that php function to include a photo into a GD graphic image. The php.net page gives some interesting examples.

 

I have now managed to include a photo inside one which I created using GD Graphics. I have used a function provided by Stefan on the php.net page.

 

However, I now have to figure out how to insert a photo that is not stored in the same directory as the php file.

I have another problem.

 

I have been able to create a jpeg image with "imagecreate" and then add the jpeg photo using ("imagecreatefromjpeg" and "imagecopymerge") by doing this using two separate scripts. This works ok.

 

However, when I try to combine both scripts into one function which creates a new image and then merges the photo into it, the photo loses a lot of the colors.

 

Is there an easy way to get round this problem?

Ok, I just had a brainwave and I think that I have solved my problem.

 

Instead of putting both scripts into one function, I created the new jpeg image using php code and I then followed that with a function which inserted the photo into the newly created image.

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.