Page 1 of 1

convert annotate doesn't go to edge

Posted: 2015-01-02T15:16:16-07:00
by Danack
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

Re: convert annotate doesn't go to edge

Posted: 2015-01-02T15:49:32-07:00
by fmw42
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

Re: convert annotate doesn't go to edge

Posted: 2015-01-02T20:31:03-07:00
by Danack
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

Re: convert annotate doesn't go to edge

Posted: 2015-01-02T21:58:26-07:00
by fmw42
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.

Re: convert annotate doesn't go to edge

Posted: 2015-01-03T06:52:51-07:00
by Danack
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

Re: convert annotate doesn't go to edge

Posted: 2015-01-03T10:53:31-07:00
by fmw42
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.

Re: convert annotate doesn't go to edge

Posted: 2015-01-11T11:19:28-07:00
by Danack
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.

Re: convert annotate doesn't go to edge

Posted: 2015-01-11T11:59:51-07:00
by magick
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

Re: convert annotate doesn't go to edge

Posted: 2015-01-11T13:41:19-07:00
by Danack
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

Re: convert annotate doesn't go to edge

Posted: 2015-01-11T14:17:37-07:00
by fmw42
Use the Imagick forum for bugs with that API. Note, it is not maintained by the developers of Imagemagick

Re: convert annotate doesn't go to edge

Posted: 2015-01-15T15:54:28-07:00
by Danack
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

Re: convert annotate doesn't go to edge

Posted: 2015-02-09T09:01:55-07:00
by Danack
This is a bug - but in the inkscape SVG converter. It doesn't show the issue in a newer version of that library.