Watermarking issues

3 posts in this topic

I just purchased BT Media gallery, and I'm running into an issue with watermarking.

I have a rather large watermark that I am applying across the image as a translucent watermark.

The image itself has transparency in it and is saved as a PNG.

When I apply the watermark a few things happen.

1) It applies the watermark with no transparency, and I have to change the transparency via the control. Not a big deal, but if I wanted (as I do) to have the translucency of the watermark change across the watermark, this is not doable. You should preserve the alpha channel of the input image if it has one and ignore the translucency setting in that case.

2) The watermark is rather large (as I stated) and when it is applied, it is being applied to thumbnails after the thumbnail is resized and thus only a portion of the watermark is appearing on the thumbnails.

3) The watermark rotation does not work at all. If I specify any option other than 0, my watermark doesn't appear at all.

In a previous gallery system (which I had to modify as it didn't support watermarking at all), I would take the original image, scale the watermark to 85% of the original image, apply it, and then scale the image for thumbnail/display sizes. This guarenteed that the watermark looked good and was visible at all sizes. I would like some way to do the same here.

At a minimum, doing the following would be beneficial.

1) if the watermark is larger than the proposed size of the image, scale the watermark down to fit within the image. [doing it this way has no impact on most people who use small watermark images -- I have reasons for choosing a large one in my use case]

2) do the operations in the following order.

a. rotate the watermark.

b. scale the watermark (as above) if needed [and it'll almost always be needed for a thumbnail except in the case of very small watermark images]

c. merge the image and the watermark preserving the alpha channelof the input image.

I am going to look at the source code myself and see about making these changes for myself, (and will feed them back into the community) since right now it doesn't do what I need at all in this respect.


Share this post

Link to post
Share on other sites

I did a bit more digging into this.

1) It appears that the file upload is always being stored as a jpg even when I upload png. I tracked this down to a bug in the upload code where the file type is determined. It uses image_type_to_mime_type, which it then passes into a function which creates the image. The case function in that routine however, uses the trailing part of the mime type, but the full mime type is being passed in. This means that (for instance) on a PNG file, it's passing in "image/png" but the function is looking for "png". When it doesn't find it, it falls through to the default case and saves the large and thumbnail images as jpg instead of the appropriate type.

2) The watermark not appearing when rotated appears to be related to the background pixel. The code calls

$bg = imagecolortransparent($watermark_r);
$watermark_r = imagerotate($watermark_r, $options['rotate'], $bg, 1);

but that ends up returning 'false' from the imagerotate which means that the rotation failed. Using a version of imagerotate without the background pixel returns a valid image but it's not pretty.. So something is going wrong there.

Hopefully these can get correctly fixed in an upcoming version.

Share this post

Link to post
Share on other sites

Hi Joseph.

Thank you so much for your topic and great advices.

But at the moment, we have many plans so we will note the problems and try to fix and implement them to next version.

I hope you will understand us.

Thanks so much.

Share this post

Link to post
Share on other sites