Jump to content


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


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.


Share this post

Link to post
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

Share this post

Link to post
Share on other sites


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.