views:

489

answers:

1

Hi!

I am creating a script that can put a 24-bit transparent PNG image as a water mark on JPG/GIF/PNG images.

So, far i had success with JPEG and PNG.

But how can i achieve same with gif files? for GIF files, watermark do appear, but without transparency.

Please help.

Thanks, Anjan

+1  A: 

GIF images use indexed color palettes. In order to combine another image (your watermark) with the GIF image, whatever image library you're using (I'm guessing gd) is probably converting the PNG to an indexed-color format which is stripping out the alpha channel when it does so.

You probably need to find a way to convince it to convert the GIF image to a non-indexed color format first, then combine it with the watermark, and then write it back to an indexed-color GIF again.

Amber
You dont have to strip out the alpha channel. You just have to downsample it to 1 bit.
Joey
While you are correct that downsampling would work in the most basic sense, in terms of result image quality it's better to downsample after combining rather than before - that way the full information available in the alpha channel is available for the combination.
Amber