Page 1 of 1

Adding a caption to an extent araea

Posted: 2019-09-29T19:53:58-07:00
by groovybanana
Hello, brand new here and brand new to ImageMagick. I've been struggling with this for hours and I have a feeling it should be an easy thing to do. For the life of me I can't figure it out.

In a nutshell, what I want to do is take an image, add space below the image to place a caption and then place the caption in that area. There are some other image processing things going on, but the above is the part that I am struggling with. This is the code I have so far.

Code: Select all

magick convert -background none -fill red -gravity center -size 300x150 caption:"This is my caption" input.jpg +swap -gravity south -composite  -gravity center -extent 2:3 -resize 300x450 -gravity north -background gray -extent 300X600 output.png
Which produces

Image

So close, but I want the caption in the gray area.

I am on windows 10, running 7.0.8-66 Q16 x64

Any help would be greatly appreciated. Thank you.

Re: Adding a caption to an extent araea

Posted: 2019-09-29T20:48:08-07:00
by fmw42
With ImageMagick 7, use magick in place of convert.

Try this:

Image

Windows code (converted from Unix)

Code: Select all

magick lena.png -set option:wd "%w" ^
( -size "%[wd]x150" -background gray -fill red -gravity center ^
-font Arial caption:"This Is My Caption" ) ^
-append lena_caption.png
Image

See
https://imagemagick.org/Usage/basics/#parenthesis
https://imagemagick.org/Usage/layers/#append_array
https://imagemagick.org/Usage/basics/#define

Re: Adding a caption to an extent araea

Posted: 2019-09-29T21:21:19-07:00
by groovybanana
Excellent, thank you so much.