convert -gravity misalignment

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
dud
Posts: 2
Joined: 2017-01-07T12:27:24-07:00
Authentication code: 1151

convert -gravity misalignment

Post by dud »

If I run the following command (copied/edited from video-contact-sheet) using imagemagick 6.9.6.8 or before, it produces neatly aligned rows of text. However since 6.9.7.1 the text to the right is cut off at the top.

Code: Select all

$ NL='
'
$ convert \( -size 1795x1 xc:white +size -font /usr/share/fonts/TTF/DejaVuSans.ttf -pointsize 14 -background white -fill black \( -gravity West \( label:Filename: label:FILENAME +append \) -font /usr/share/fonts/TTF/DejaVuSans.ttf label:'File size: SIZE' label:'Length: LENGTH' -append -crop 1813x69+0+0 \) -append \( -size 1813x69 -gravity East -fill black -annotate +0-1 "Dimensions: RESOLUTION${NL}Format: FORMAT${NL}FPS: FPS" \) -bordercolor white -border 9 \) out.png
Is it possible to attach the output of each version for comparison?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert -gravity misalignment

Post by fmw42 »

Is it possible to attach the output of each version for comparison?
Upload your images to some free hosting service such as dropbox.com and post the URLs here.
dud
Posts: 2
Joined: 2017-01-07T12:27:24-07:00
Authentication code: 1151

Re: convert -gravity misalignment

Post by dud »

6.9.6.8:
Image
6.9.7.1:
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert -gravity misalignment

Post by fmw42 »

You need to put a +repage after your crop ...\) -append. Rewriting so that it is easier to read and using arial font since I did not have your font:

Code: Select all

NL='
'
convert \( -size 1795x1 xc:white +size -font arial -pointsize 14 -background white -fill black \
\( -gravity West \
\( label:Filename: label:FILENAME +append \) \
-font arial label:'File size: SIZE' label:'Length: LENGTH' -append -crop 1813x69+0+0 \) \
-append +repage \
\( -size 1813x69 -gravity East -fill black -annotate +0-1 "Dimensions: RESOLUTION${NL}Format: FORMAT${NL}FPS: FPS" \) \
-bordercolor white -border 9 \) \
out.png
But your code is way to complicated and mixes label and annotate. The following is much simpler and use \n directly rather than your NL variable, which could have been written NL="\n". It also just uses -annotate. Furthermore, no parentheses are needed.

Code: Select all

convert -size 1813x69 xc:white -font arial \
-pointsize 14 -background white -fill black \
-gravity West \
-annotate +0+0 'Filename: FILENAME\nFile size: SIZE\nLength: LENGTH' \
-gravity East \
-annotate +0+0 'Dimensions: RESOLUTION\nFormat: FORMAT\nFPS: FPS' \
-bordercolor white -border 9 \
out.png
Post Reply