PHP Image manipulation

I’ve got a script that takes two images, and creates one image from
them. The first image is a “background” image, over which I’m going to
place a “logo” image. It’s pretty simple:

<?php
$new_image = ImageCreate(200, 200);
$bg_image = ImageCreateFromJpeg(“bg_image_file.jpg”);
$logo_image = ImageCreateFromPng(“logo_image_file.jpg”);

// copy “bg_image_file.jpg” to our new image
ImageCopyResized($new_image, $bg_image_file, 0, 0, 0, 0, 200, 200,
200, 200);

// copy “logo_image_file.jpg” and place it on top of the above
// created image
ImageCopyResized($new_image, $logo_image_file, 50, 50, 0, 0, 100, 50,
100, 50);
?>

this creates the file as I would expect. My issue now is this: if
“logo_image_file.png” has a transparent background, when it gets laid
over the newly created image, it is given a white background, which
doesn’t work because the “bg_image_file.jpg” isn’t white. The background
image may be one of any given number of colors. The only transparency
support I can seem to find is:

<?php
$color = ImageColorAllocate($logo_image, 255, 255, 255);
ImageColorTransparent($logo_image, $color);
?>

This allows me to set ONE COLOR in the image as transparent. So, if I
know I’m going to place the logo on a red background, I create the logo
file with a red background, and it will look ok. But I don’t know what
color I’m going to have to place the logo over, and making a logo image
file for each possible color kind of defeats the purpose.

Anyone have any ideas or experience in this area?

-Mike K.

Re: PHP Image manipulation

> Anyone have any ideas or experience in this area?
>
> -Mike K.

I’ve had this exact headache with an asp component i’ve been using to do
just this.I kind of gave up as it was driving me nuts. I’d like to see how
you progress, it might kick me in the right direction.

Adam
http://t-shirtme.com