Overlaid Watermark larger than overlaying image

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
ceodecasteo
Posts: 2
Joined: 2017-05-02T02:18:59-07:00
Authentication code: 1151

Overlaid Watermark larger than overlaying image

Post by ceodecasteo »

Hi,
i have a question related to the image composition.

I have a watermark.jpg with dimension 1649 × 100 pixels.
First I reduce it to 50%, so the new dimensions are 824 x 50 pixels; then I use it as watermark for other images.

There are two cases:
(i) An image A with width's dimension greater than 824:
there is no problem, the watermark is enterely displayed.

(ii) An image B with width's dimension lower than 824.
In this case I have a problem: the watermark is truncated.
Otherwise the image B should be enlarged (in width direction) in order to display the watermark.
Is possibile to achieve this goal? I try with some combinations of resize, but I can't be able ...

My command is like that:

convert image_A.jpg -resize 1181x1181\
\( watermark.png -resize 50%x50% \) -gravity South -geometry +0+80 -composite\
image_A_with_watermark.jpg

Thank you in advance,
Alessandro
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Overlaid Watermark larger than overlaying image

Post by snibgo »

It can be done in a single command, but it's a bit messy.

Personally, I'd do it in a script:

1. Resize the image and get its dimensions.
2. Resize the watermark and get its dimensions. (But isn't this constant? So no need to repeat it?)
3. If the image is too narrow, stretch it.
4. Apply the watermark.
snibgo's IM pages: im.snibgo.com
ceodecasteo
Posts: 2
Joined: 2017-05-02T02:18:59-07:00
Authentication code: 1151

Re: Overlaid Watermark larger than overlaying image

Post by ceodecasteo »

Thank you very much for your suggestions.
Alessandro
Post Reply