elboletaire / Watimage

:framed_picture: PHP image manipulation class
https://elboletaire.github.io/Watimage
Other
25 stars 17 forks source link

Using a png file to watermark a gif image. #6

Closed daniel-berger-nemeth closed 9 years ago

daniel-berger-nemeth commented 9 years ago

If i try to watermark an gif image with a png watermark file, the gif is transparent, but the png watermark has a black background.

screen shot 2014-11-21 at 21 16 25

elboletaire commented 9 years ago

Sorry but, can you describe your problem? If you're using a watermark with a black background there's no issue here.

I understand that your png file is transparent and, when applying the watermark, it turns black. Is this right?

daniel-berger-nemeth commented 9 years ago

Yes, this is right. Both should be transparent after the watermark.

elboletaire commented 9 years ago

I'll try to fix it then.

elboletaire commented 9 years ago

It seems that when I made Watimage I didn't expected gif images to be used as watermarks, instead, the code is built just for using png images as watermark.

I'll try to work on it during these days. Theoretically the imagecopyresampled used in the internal method resize_png_image (which will be renamed, as it names clearly states that it's just for png images) does not maintain the alpha for gif images. Instead I'll need to use imagecopyresized method.

This stackoverflow answer saved me a lot of time. :smile: Now I expect the theory to be possible... :sweat_smile:

elboletaire commented 9 years ago

HHhmmm... after testing it by myself I can only see the script failing when using gif images as background (if those images have alpha they loose it) but watermarking gif files with png does not negatively affect the watermark.

Are you sure that the image that gains a black background is the png image? Isn't it the gif image used as backgruond?

Here are my tests using gif images as background...

Gif with gif

watermark_gif_with_gif

Gif with png

watermark_gif_with_png

As you can see, the watermark image doesn't loose it's transparency, whilst the gif image used as background does.

I've also tested any other circumstance (using always gif or png files for watermarks) and there are no more failures, so I'll try to fix this issues.