Adding a caption to an extent araea

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
groovybanana
Posts: 2
Joined: 2019-09-29T19:43:58-07:00
Authentication code: 1152

Adding a caption to an extent araea

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

Re: Adding a caption to an extent araea

Post 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
groovybanana
Posts: 2
Joined: 2019-09-29T19:43:58-07:00
Authentication code: 1152

Re: Adding a caption to an extent araea

Post by groovybanana »

Excellent, thank you so much.
Post Reply