convert annotate doesn't go to edge

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
Danack
Posts: 73
Joined: 2013-10-14T10:00:25-07:00
Authentication code: 6789

convert annotate doesn't go to edge

Post by Danack » 2015-01-02T15:16:16-07:00

It appears that the text drawn by annotate doesn't reach the right side of the image when the text is rotated. Instead there is a blank column on that edge.

No stroken and there is a blank column:

convert \
-size 100x100 xc:white \
-pointsize 17 \
-weight 400 \
-fill black \
-stroke none \
-annotate 270x270+101+52 'test' \
61806Convert.png

Image

Black stroke and the text goes to edge:

convert \
-size 100x100 xc:white \
-pointsize 17 \
-weight 400 \
-fill black \
-stroke black \
-annotate 270x270+101+52 'test' \
61806Convert_black.png

Image

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

Re: convert annotate doesn't go to edge

Post by fmw42 » 2015-01-02T15:49:32-07:00

I believe this is just how it works, since in the first case, the stroke is invisible, but the placement is the same. See

http://www.imagemagick.org/Usage/draw/#coordinates
http://www.imagemagick.org/Usage/draw/#stroke

Danack
Posts: 73
Joined: 2013-10-14T10:00:25-07:00
Authentication code: 6789

Re: convert annotate doesn't go to edge

Post by Danack » 2015-01-02T20:31:03-07:00

Sorry, perhaps I have poorly described the issue.

The fill in the letters should be drawn in the last column of the image regardless of the stroke.

The fill is drawn correctly when the stroke is set to black, red, white or presumably any coloured value. It's just not draw at all when the stroke it set to transparent.

i.e. these two commands show the lack of pixels when the stroke is transparent, and they are there when the stroke has even a tiny bit of alpha:

convert \
-size 100x100 xc:white \
-pointsize 17 \
-weight 400 \
-fill black \
-stroke "rgba(0,0,0,0.01)" \
-strokewidth 0 \
-annotate 270x270+101+52 'test' \
61806Convert.png


vs

convert \
-size 100x100 xc:white \
-pointsize 17 \
-weight 400 \
-fill black \
-stroke "rgba(0,0,0,0.0)" \
-strokewidth 0 \
-annotate 270x270+101+52 'test' \
61806Convert.png

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

Re: convert annotate doesn't go to edge

Post by fmw42 » 2015-01-02T21:58:26-07:00

The text is aligned at the edge, but the stroke part is invisible.

If you do what you say, then the result will be shifted whenever you do not use stroke and it will need special coding. Stroke is always there, but invisible without -stroke. I think the developers do this intentionally so that there is no shift when stroke is or is not used. There should not be any difference in the text positioning with or without -stroke. This is my understanding.

I will let the developers comment from here. They can say whether this is a bug or by design as I surmise.

Danack
Posts: 73
Joined: 2013-10-14T10:00:25-07:00
Authentication code: 6789

Re: convert annotate doesn't go to edge

Post by Danack » 2015-01-03T06:52:51-07:00

One more pair of examples then to show why I think it's a bug. The difference between the two commands below is one draws the image at 25x40 and then crops to 20x40, and the other draws the image at 20x40. I would expect the end images to be identical, but they are not.


convert \
-size 25x40 xc:white \
-pointsize 17 \
-weight 400 \
-fill black \
-stroke 'none' \
-annotate 270x270+23+32 'test' \
-crop 20x40+0+0 \
-sample 1000% \
61806Convert_cropped.png


convert \
-size 20x40 xc:white \
-pointsize 17 \
-weight 400 \
-fill black \
-stroke 'none' \
-annotate 270x270+23+32 'test' \
-crop 20x40+0+0 \
-sample 1000% \
61806Convert_uncropped.png

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

Re: convert annotate doesn't go to edge

Post by fmw42 » 2015-01-03T10:53:31-07:00

I think you are missing the point. It is the same text drawn to the edge but the stroke is invisible in one case.

P.S. You can always crop off the last column if you want.

Danack
Posts: 73
Joined: 2013-10-14T10:00:25-07:00
Authentication code: 6789

Re: convert annotate doesn't go to edge

Post by Danack » 2015-01-11T11:19:28-07:00

I'm pretty sure this is a bug. I was going to post a whole set of examples but it may be easier to just post a similar issue:

Code: Select all

convert \
-size 100x20 xc:white \
-pointsize 24 \
-weight 400 \
-fill black \
-stroke 'none' \
-annotate 0x0+0+22 'test' \
-rotate 5 \
-sample 1000% \
test_below_rotate_5_uncropped.png
produces the image:

Image

Where the text is cropped even though it's many pixels from the edge.

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

Re: convert annotate doesn't go to edge

Post by magick » 2015-01-11T11:59:51-07:00

Try this command:
  • convert -size 100x20 xc:white -pointsize 24 -weight 400 -fill black -stroke 'none' -annotate 5x5+0+17 'test' -sample 1000% test_below_rotate_5_uncropped.png

Danack
Posts: 73
Joined: 2013-10-14T10:00:25-07:00
Authentication code: 6789

Re: convert annotate doesn't go to edge

Post by Danack » 2015-01-11T13:41:19-07:00

That produces the image that I would expect. And I've just realised why that last example I gave is dumb; sorry about that.

I still think the text being cropped to a pixel narrower than the image, when it goes off the right edge of the image is a bug though.

To be clear, I'm not reporting this as an issue for an image I want make, I'm reporting it as user having an issue in PHP Imagick: https://bugs.php.net/bug.php?id=61806

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

Re: convert annotate doesn't go to edge

Post by fmw42 » 2015-01-11T14:17:37-07:00

Use the Imagick forum for bugs with that API. Note, it is not maintained by the developers of Imagemagick

Danack
Posts: 73
Joined: 2013-10-14T10:00:25-07:00
Authentication code: 6789

Re: convert annotate doesn't go to edge

Post by Danack » 2015-01-15T15:54:28-07:00

Use the Imagick forum for bugs with that API. Note, it is not maintained by the developers of Imagemagick
Yes I know; I'm one of the developers of Imagick. A user reported to me, I've looked at it, and the convert tool has the same behaviour (that looks incorrect) so I'm reporting it upstream, as the behaviour seems independent of whether ImageMagick is called through the command line or an API.

I realised that actually the issue seems to happen without any need for rotation. I've put some examples below that use 'red', 'none', and 'white' as the stroke colours. I realise you've said that:
The text is aligned at the edge, but the stroke part is invisible.
That doesn't happen for other stroke colors and looks incredibly wrong. I'm sorry if I'm missing something that I should be understanding.

Red stroke, text goes to edge:
Image

None stroke, text doesn't go to edge:
Image

White stroke, text goes to edge:
Image



convert \
-size 60x60 xc:white \
-pointsize 96 \
-weight 400 \
-fill black \
-stroke red \
-annotate 0x0+0+70 'test' \
-sample 1000% \
61806Convert_red.png


convert \
-size 60x60 xc:white \
-pointsize 96 \
-weight 400 \
-fill black \
-stroke white \
-annotate 0x0+0+70 'test' \
-sample 1000% \
61806Convert_white.png


convert \
-size 60x60 xc:white \
-pointsize 96 \
-weight 400 \
-fill black \
-stroke none \
-annotate 0x0+0+70 'test' \
-sample 1000% \
61806Convert_none.png

Danack
Posts: 73
Joined: 2013-10-14T10:00:25-07:00
Authentication code: 6789

Re: convert annotate doesn't go to edge

Post by Danack » 2015-02-09T09:01:55-07:00

This is a bug - but in the inkscape SVG converter. It doesn't show the issue in a newer version of that library.

Post Reply