Using gravity setting with label:
Posted: 2016-12-09T13:54:47-07:00
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"...
That outputs these two PNG files...
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.
Code: Select all
magick -pointsize 96 label:"A LABEL!" -gravity center label:"A LABEL!" test%0d.png
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.