Sometimes, it's nice to have the watermark image scaled to some percentage of the target image width - for example, when watermarking a small-ish image (say, 320x200) your watermark image (which may be fine for larger images) may appear to be overwhelmingly large if the watermark is not scaled down.

In another case, a small watermark suitable to use with small images may be barely visible on a very large (1800x1600) image.

So, typically, when I apply a watermark, I scale the watermark to be proportional to the target image.

I realize that not everyone will want this functionality, so, ideally, this would be an optional setting or perhaps one could set a threshold ("Scale watermark to NN % of width if original image width is < $min_width || > $max_width"). Anyway, I'm still thinking about this, any feedback welcome.

--

Attached is a proof-of-concept patch against the DRUPAL-4-7 cvs that provides an example of this functionality. I've tested it with 32-bit PNG watermark images with an alpha channel, and it works fine. I've not tested it with other types of watermark source images.

Note: this experimental/proof-of-concept patch 'recycles' the 'percentage' in watermark_form_alter(), so, if you apply this patch, be sure to re-set that value in the admin/settings/image page before uploading any new images.

Examples at:

http://amadorable.com/view-mt-zion-fog-shrouded-valley
http://amadorable.com/view-mt-zion-fog-shrouded-valley?size=button

http://amadorable.com/view-mt-zion-fog-shrouded-valley-panorama
http://amadorable.com/view-mt-zion-fog-shrouded-valley-panorama?size=button

Or, just peruse the galleries at:
http://amadorable.com/image

CommentFileSizeAuthor
watermark.module.scaling_watermark.patch5.36 KBmcurry

Comments

mcurry’s picture

Status: Active » Needs work

Changing status. Please review patch, and comment. I'll keep working on this, but I want to gather feedback from the module author and those using the module.

kbahey’s picture

Looks like a good feature to have.

Once you bring this to a usuable patch (non-experimental, with option, ...etc.), I will apply it.

mcurry’s picture

Also, the current patch implementation does not allow user-specified alpha blending - the alpha blending is determined by the watermark file's transparency information. This means that the foreground of the watermark won't be alpha-blended unless you set the foreground to have alpha transparency. I'm working on this...

Off-topic: I found a useful utility (AlphaMix) that allows you to view a png file's alpha transparency info. And this page has a bunch of other resources.

schnizZzla’s picture

@inactivist
your code has been recycled ^_^

http://drupal.org/node/153995

schnizZzla’s picture

Status: Needs work » Closed (duplicate)