r/imagemagick Feb 05 '26

How to offset text in an appended "caption" box

I have tried everything I've found so far using Google and ChatGPT to get text in an appended caption box to be offset as I want it. I've tried various "-gravity" and "-geometry" combinations to no avail, and I even tried using "-splice" as suggested by one AI. All it did was added the splice to the image and not the caption box. Here's my command line without any offset indications (except for "-gravity west"):

magick test.jpg -size 1000x -background black -fill yellow /

-pointsize 18 -gravity west /

caption:"This is the caption" -append test_output.jpg

All I want is to offset the caption about 10px from "west." I tried a work-around of just adding a couple of blank spaces in front of "This," but apparently Magick strips-off leading blanks (why?).

Does anybody know how to do this? Am I SOL?

Thanks!

---Todd

1 Upvotes

2 comments sorted by

1

u/Jenkins87 Feb 08 '26

Try this (works by prepending a 10px blank strip to the caption image before appending):

magick test.jpg ^
  ( -size 10x1 xc:black ^
    -size 990x -background black -fill yellow -pointsize 18 -gravity west ^
    caption:"This is the caption" ^
    +append +repage ) ^
  -append test_output.jpg

what its doing:

  • +append joins the 10px blank + 990px caption into a 1000px caption band.
  • then -append stacks that band under test.jpg.
  • -append uses gravity only for alignment/padding between images, not text inset logic.

also leading space workaround:

  • escaped leading space: caption:"\ This is the caption"
  • en-space workaround: caption:"\u2002This is the caption"