Page 1 of 1

Annotate not honoring default gravity with IM7

Posted: 2016-04-07T07:27:00-07:00
by GeeMack
Using "ImageMagick-7.0.0-0~beta20160329-Q16-HDRI-x64-static.exe" on Windows 7 64, there seems to be some odd behavior of "annotate" and "draw text" when no gravity setting is specified. These commands...

Code: Select all

magick ^
   -size 600x100 ^
   canvas:white ^
   -pointsize 48 ^
   -draw "text 0,0 'abc123'" ^
      testing1.png

magick ^
   -size 600x100 ^
   canvas:white ^
   -pointsize 48 ^
   -annotate +0+0 "abc123" ^
      testing2.png
... result in the "abc123" being placed almost entirely outside the canvas at the left top. And this command...

Code: Select all

magick ^
   -size 600x100 ^
   label:"abc123" ^
   -pointsize %[label:pointsize] ^
   -fill green ^
   -annotate +2+2 "abc123" ^
      testing3.png
... should result in "abc123" oriented to the upper left corner by the "label" operation with a best-fit pointsize, then use that pointsize to place a green copy of "abc123" over the label but offset by +2+2. The green one ends up outside the canvas just barely visible at the left top.

Specifying a gravity setting seems to resolve the problem, even if it's the default of "northwest". This works...

Code: Select all

magick ^
   -size 600x100 ^
   canvas:white ^
   -pointsize 48 ^
   -gravity northwest ^
   -draw "text 0,0 'abc123'" ^
      testing4.png
This doesn't...

Code: Select all

magick ^
   -size 600x100 ^
   canvas:white ^
   -pointsize 48 ^
   -gravity center ^
   -draw "text 0,0 'abc123'" ^
   +gravity ^
   -draw "text 0,0 'def456'" ^
      testing5.png
I would think the "annotate" and "draw text" operations should honor the default gravity setting of northwest, either when gravity is not specified or after returning it to the default with "+gravity", but it's placing those pieces of text outside the canvas instead.

Re: Annotate not honoring default gravity with IM7

Posted: 2016-04-07T09:18:08-07:00
by magick
Its possible ImageMagick defaulted to NorthWest gravity in older releases but when we unified the command-line we defaulted the gravity to undefined. As you suggested, the proper fix is to set the gravity to NorthWest.

Re: Annotate not honoring default gravity with IM7

Posted: 2016-04-07T09:24:11-07:00
by fmw42
Is it possible to set the default to NW in IM 7? Otherwise, that might break a lot of scripts that assume the default is NW.