Jump to content

Troubles with GD pictures...


clonetrooper9494

Recommended Posts

I am trying to make a simple JS/PHP/HTML program that lets you make your own icon, and then download it. There would be movable shapes and junk like that. Well, anyways, I am trying right now just make a picture with 2 other smaller pictures placed in it... I was looking on PHP.net, and I could find anything. I have no clue what I am doing really... I have something...

<?phpfunction LoadGif ($imgname){	$im = @imagecreatefromgif ($imgname);	return $im;}header("Content-Type: image/gif");$img = LoadGif("http://www.e-zcheese.com/images/home/cheese.gif");$img += LoadGif("http://offtopic.kimcm.dk/Images/mouse_and_cheese.gif");imagegif($img);?>

http://www.clone-drone.net/home/image_fun/view.phpWhich outputed an error... :)So, I also wanted them to be put in by X and Y corrdinates too, is there a function that does that? Or something that I don't understand, like I can't have 2 images fused in to one at all?

Link to comment
Share on other sites

The imagecopyresampled function can resize or copy image information. In that code you assign the return value of imagecreatefromgif to a variable and then try to add that to another variable using addition. All of the imagecreate functions return an image handle, it's a resource for other functions, not actual image data. And it doesn't make much sense to use mathematical addition on two resources.

Link to comment
Share on other sites

A (slightly!) different idea. Create an image resource ($dest) with imagecreatetruecolor. This func calls for width and height, so make it the size of the final, combined image. Use your LoadGif to get resources for the two source images. Then you'll need two calls to imagecopy(). The first places $gif1 into $dest at the correct coords; the second places $gif2 into $dest at its own correct coords. (You can add, right?) Then imagegif($dest) sends it out.But why work with gifs? I really don't know what you're up to, of course, but I see a big risk of combining 2 very different palettes into something icky. FWIW, the GD jpeg compression is pretty good. IMO.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...