Jump to content

How To Set Image As Background of Image in GD Library


Recommended Posts

Hi All
I want to set an imge(.jpeg/.gif) as the background of
my own created image through the GD library.
[b]let me explain[/b]:
i have an [b]example.jpeg[/b] image and through the GD library i am greating an rectangle and i want to set [b]example.jpeg as the background of this rectangle[/b].
please help me.

Link to comment
Share on other sites

nothing special here - create your canvas using 'imagecreatefromjpeg' or 'imagecreatefromgif' instead of 'imagecreate' or 'imagecreatetruecolor'. then you just lay down whatever you want just as normal. for example:

$im = imagecreatefromjpeg("myfile.jpg");

$red = imagecolorallocate($im, 255,0,0);
imagerectangle($im, 20,20,120,120, $red);


hope that helps
Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

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

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.