Gravity center + annotate behavior change in 6.9.2-3

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
sam.saffron
Posts: 2
Joined: 2015-09-23T17:45:27-07:00
Authentication code: 1151

Gravity center + annotate behavior change in 6.9.2-3

Post by sam.saffron »

We use the awesome Image Magick for letter avatar generation at Discourse, recently we upgraded from 6.9.1-3 to 6.9.2-3

See more at: https://meta.discourse.org/t/letter-ava ... date/33671

We use the following command to create letter avatars

Code: Select all

convert -size 360x360 xc:'rgb(198,125,40)' -pointsize 280 -fill '#FFFFFFCC' -font 'Helvetica' -gravity Center -annotate -0+26 'A' -depth 8 'avatar.png'
  
Letter was perfectly centered in 6.9.1 but now requires a +42 offset (as opposed to +26) to be in the middle.

Any ideas what happened here?

Is there a format here that will render the same image on both 6.9.2 and 6.9.1 ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Gravity center + annotate behavior change in 6.9.2-3

Post by fmw42 »

What do you mean by "in the middle"? If the letter A is rendered with -annotate +0+0, it is not rendered to be centered. That is a property of the font metric for that letter and font.

I added -debug annotate to my command with -annotate +0+0 and get

Code: Select all

 Metrics: text: A; width: 183.891; height: 280; ascent: 216; descent: -65; max advance: 420; bounds: 4.10938,0  183.344,200.5; origin: 187,0; pixels per em: 280,280; underline position: -3.20312; underline thickness: 1.57812
2015-09-24T09:53:15-07:00 0:00.000 0.000u 6.9.2 Annotate convert[409]: annotate.c/RenderFreetype/1252/Annotate
  Font /System/Library/Fonts/Helvetica.dfont; font-encoding none; text-encoding none; pointsize 280
Can you post examples of the results of your command using -annnotate +0+0 from your two versions of IM?

Perhaps you have a change of version of one of the font delegates such as freetype or fontconfig.
womble
Posts: 2
Joined: 2015-10-04T21:42:55-07:00
Authentication code: 1151

Re: Gravity center + annotate behavior change in 6.9.2-3

Post by womble »

I work with Sam at Discourse, he's asked me to dig into this. Fun times...

I've bisected the commit that introduced the problematic behaviour to 61315aae, which refers to viewtopic.php?f=3&t=27451. Interestingly, I can still reproduce the problem referenced in that thread with current HEAD (b94400f5). As an added bonus, of course, it also causes the problems we're seeing...

As far as generating examples with -annotate +0+0, images generated with -annotate +0+0 are identical; the problem only presents itself for annotations we make offset. The problem is that a lot of our annotations have to be made with an offset, because for reasons unknown the "centre" of the letter isn't really the centre.

For the command Sam originally posted, here are the resulting images:

On 234ea93e:

Image

On b94400f5:

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

Re: Gravity center + annotate behavior change in 6.9.2-3

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.9.2-4 Beta available by sometime tomorrow. Thanks.
womble
Posts: 2
Joined: 2015-10-04T21:42:55-07:00
Authentication code: 1151

Re: Gravity center + annotate behavior change in 6.9.2-3

Post by womble »

I can confirm that d11120d no longer exhibits the issue we were having. Thanks for the quick fix!
Post Reply