tags:

views:

457

answers:

2

I am using PHP & GD library.

I want to draw an image (say this one: http://www.gravatar.com/avatar/107f2fafb2d29fedc3783b141139a878?s=128&d=identicon&r=PG) over another image: http://www.geekpedia.com/gallery/fullsize/simplistic-windows-wallpaper.jpg at specified coordinates (top-left or top-right or anywhere in the image).

How to do that using PHP and GD library.

+3  A: 

imagecopy() or imagecopymerge(). It's documentation brings exemples too.

Havenard
@Havenard: both of these methods are good, and working perfect. But I am facing one problem which is, I want to resize my image (which I want to apply on another image) to 32x32 size, is there any method using GD library which will do this for me, otherwise I have to create another script which will resize the image first and then it will apply it on another image, that may cause the slowdown. So please tell me any method using which I can resize my image to 32x32 size before applying it to another image.
Prashant
A: 

imagecopyresampled() or imagecopyresized() should do exactly what you want.
(Despite its name, imagecopyresampled does resize as well.)
They take some or all of the source image, resize it, and copy it into the destination image. If the source image isn't square, you can either crop or distort it as it is copied.

...Tom

Tom Robinson