Annotate not honoring default gravity with IM7

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.
Locked
User avatar
GeeMack
Posts: 757
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Annotate not honoring default gravity with IM7

Post 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.

User avatar
magick
Site Admin
Posts: 11254
Joined: 2003-05-31T11:32:55-07:00

Re: Annotate not honoring default gravity with IM7

Post 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.

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

Re: Annotate not honoring default gravity with IM7

Post 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.

Locked