Page 1 of 1

Using gravity setting with label:

Posted: 2016-12-09T13:54:47-07:00
by GeeMack
This is an extension of a conversation found at THIS link in the Users section. Using IM 7.0.3-9 on Windows 10 64, when I generate a label image with a setting of "-gravity center" (and most others), a few pixels get clipped off the first character at left edge of the image. Here is a command to create two sample images, one without a "-gravity" setting and the other set to "center"...

Code: Select all

magick -pointsize 96 label:"A LABEL!" -gravity center label:"A LABEL!" test%0d.png
That outputs these two PNG files...

Image

Image

The second example there shows how that left side gets pushed out of the viewport. This will occur with the default font or with several other common Windows fonts I've tested. It occurs at any pointsize, but the results are more obvious with a larger size like I used for the examples.

The problem is more pronounced when the label text ends with an exclamation point, colon, or pipe, or other tall narrow characters, but is also evident when ending with normal letter/number characters.

A suggestion was made in the opening conversation to escape the exclamation point with a caret or backslash, but neither seem to affect the results.

Different gravity settings may change the results by a few pixels, but when using most settings the problem persists. And although gravity wouldn't generally be a concern when creating a label, it's not uncommon to have a particular gravity setting come before a label in a command for other reasons.

After testing this a variety of ways with different fonts and sizes, the results lead me to believe this is a bug.

Re: Using gravity setting with label:

Posted: 2016-12-09T16:03:16-07:00
by fmw42
I can reproduce on my Mac OSX in IM 7.0.3.9 Q16.

Code: Select all

magick -pointsize 96 label:"A LABEL\!" -gravity center label:"A LABEL\!" tmp_%d.png
But on unix, I think you have to escape the !. I get an error message without it.

Code: Select all

-bash: !": event not found
P.S. You can use +gravity to turn off centering such as where I reverse the order above:

Code: Select all

magick -pointsize 96 -gravity center label:"A LABEL\!" +gravity label:"A LABEL\!" tmp_%d.png

Re: Using gravity setting with label:

Posted: 2016-12-10T08:49:29-07:00
by magick
Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ http://www.imagemagick.org/download/beta/ by sometime tomorrow.