Watermark size should depend on original size

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
sven.fischer.de
Posts: 2
Joined: 2012-09-13T05:23:06-07:00
Authentication code: 67789

Watermark size should depend on original size

Post by sven.fischer.de »

Hi,

could you please tell me the solutions for resizing the watermark to a fixed percentance of the size of the original picture. All solutions I have found just resized the watermark ignoring the dependance.

So this I what I found, but how to modify it:

Code: Select all

composite  -gravity southeast  \( Watermark.png -resize 25% \) original-image.jpg
Target: Watermark size should always be 25% of the original picture.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Watermark size should depend on original size

Post by fmw42 »

composite -gravity southeast \( Watermark.png -resize 25% \) original-image.jpg
There is no specified output image in your command.


In IM 6, you must find the size of the background image first with some variables. Then compute 25% of them. Then feed that to your -resize.

In unix,

ww=`convert backgroundimage -format "%[fx:.25*w]" info:`
hh=`convert backgroundimage -format "%[fx:.25*h]" info:`
composite -gravity southeast \( Watermark.png -resize ${ww}x${hh} \) original-image.jpg resultimage.jpg

I believe that what you want will be doable in IM 7 which is under alpha development right now. But Anthony can explain further.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Watermark size should depend on original size

Post by anthony »

IN IMv7 you can do this in the one command. But it is not complete, working, but not complete.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
sven.fischer.de
Posts: 2
Joined: 2012-09-13T05:23:06-07:00
Authentication code: 67789

Re: Watermark size should depend on original size

Post by sven.fischer.de »

Thanks guys for your help, the script works perfect!

Additional I'm happy to hear that it will be implementet in future versions, as (in my opinion) it's very important for running a wiki for example. Users upload different picture sizes and the watermark should depend on percentence size of course.

Thanks also for programming the swiss-army-knife tool.

Cheers from Germany,

Sven
Post Reply