Convert Watermark Bash Script to CLI Command

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?".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert Watermark Bash Script to CLI Command

Post by fmw42 »

Are you on Windows or a Unix type system. See my subsequent post above to the one you quoted. You are not using the commands that I recommended right above your last post here.

Also do not put spaces after the line ending \
buchert
Posts: 36
Joined: 2015-02-13T11:15:29-07:00
Authentication code: 6789

Re: Convert Watermark Bash Script to CLI Command

Post by buchert »

Those commands work, only I'd prefer a command that automatically sizes the watermark text based on the dimensions of the image. In my bash script there's a setting *0.06000". I don't see that incorporated into these commands.

Code: Select all

export imageheight=$(echo "$(echo "$imagesize" | cut -f2 -d',')*0.06000" | bc)
I'm using Git Bash on Windows 10.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert Watermark Bash Script to CLI Command

Post by fmw42 »

Those commands work, only I'd prefer a command that automatically sizes the watermark text based on the dimensions of the image
You can do that with IM 7.
buchert
Posts: 36
Joined: 2015-02-13T11:15:29-07:00
Authentication code: 6789

Re: Convert Watermark Bash Script to CLI Command

Post by buchert »

fmw42 wrote:
Those commands work, only I'd prefer a command that automatically sizes the watermark text based on the dimensions of the image
You can do that with IM 7.
So this code should do that then?

Code: Select all

magick "$file" -set option:dim "%wx%h" \
\( -background '#000000' -fill white -gravity center -size "%[dim]" caption:"$caption" \) \
-gravity south -composite "$file"
It just hangs when I run it.

I'm using ImageMagick 7.0.3-7 Q16 on 64-bit Windows 10 with Git Bash.

magick -version
Version: ImageMagick 7.0.3-7 Q16 x64 2016-11-15 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert Watermark Bash Script to CLI Command

Post by fmw42 »

You keep going back to the wrong command line. See viewtopic.php?f=1&t=31002&p=140872#p140872

Also check your arguments to be sure they are what you think they should be.
buchert
Posts: 36
Joined: 2015-02-13T11:15:29-07:00
Authentication code: 6789

Re: Convert Watermark Bash Script to CLI Command

Post by buchert »

Is it possible to add a border to the bottom of an image that is 10% the height of the image, and then overlay text on that border that automatically sizes to the height of the border?

As of now I've changed -background to none and have to manually create the border and then run this command:

Code: Select all

magick 0000.jpg -set option:dim "%w" \
\( -background none -font Times-New-Roman -fill white -gravity center -size "%[dim]x250" label:"Testing" \) \
-gravity south -composite 0_0.jpg
But for every image the dimensions change, so through trial and error I have to modify "%[dim]x250" to the correct size so that the text extends to the height (or doesn't surpass) of the border.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert Watermark Bash Script to CLI Command

Post by snibgo »

You set dim to just the width, but you could set it to both width and height (with "x") between them. The height could be an fx expression.

Code: Select all

-set option:dim "%wx%[fx:h*0.1]"
Then use:

Code: Select all

-size "%[dim]"
snibgo's IM pages: im.snibgo.com
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Convert Watermark Bash Script to CLI Command

Post by anthony »

Did you want to overlay of top of the image, or append to the side of the image?

See Annotating Images for LOTS of different techniques.
http://www.imagemagick.org/Usage/annotating/#annotating
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply