Page 1 of 1

Improving my "caption:" code

Posted: 2019-09-20T23:26:39-07:00
by Anton79
Hi there,
I'm not a great whizz with linux scripting etc.
I'm running ImageMagick 6.9.10-14 Q16 x86_64 20181023 as this is the version my Ubuntu comes with and I got a bit lost with the manual update instructions.

I love the text flow abilities of the "caption:" option but want the caption to be on a new blank border so I can see the full original image.
I've got a solution working, its not pretty though. Perhaps someone can suggest a performance improvement using the ImageMagick 6.9.10-14 ?
Here is my code. As you see, I run convert twice which I'm guessing isn't the best way of doing things:

height=`identify -format %h "$fileorig"`
spl=$(expr $height / 10) ; # controls height of the box at the bottom

convert "$fileorig" -gravity South -splice 0x$spl "$filenew"

convert -background gold -fill black -gravity center -size ${width}x$spl \
caption:"$comment" \
"$filenew" +swap -gravity south -composite "$filenew"

Your suggestions would be greatly appreciated!

Re: Improving my "caption:" code

Posted: 2019-09-21T10:33:52-07:00
by fmw42
You never defined width, but use it. Nevertheless, try this.

Code: Select all

declare `convert "$fileorig" -format "HH=%[fx:h/10]\nWW=%w\n" info:`
convert "$fileorig" \
-size ${WW}x${HH} -background white -fill black -undercolor gold -gravity center caption:"$comment" \
-append "$filenew"

Re: Improving my "caption:" code

Posted: 2019-09-21T22:22:45-07:00
by Anton79
Hi fmw42, Thanks very much for your help!
That took the elapsed run time in processing my test folder down from 45 seconds to 15 seconds.
A funny thing is happening though. All looks good in Nautilus in grid view. Gold box with black captions. But when you open the jpgs in Image Viewer or Shotwell Viewer only a white box displays and no caption. I look forward to your suggestions!