convert annotate doesn't go to edge
convert annotate doesn't go to edge
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
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
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
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert annotate doesn't go to edge
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
http://www.imagemagick.org/Usage/draw/#coordinates
http://www.imagemagick.org/Usage/draw/#stroke
Re: convert annotate doesn't go to edge
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
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert annotate doesn't go to edge
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.
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
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
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert annotate doesn't go to edge
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.
P.S. You can always crop off the last column if you want.
Re: convert annotate doesn't go to edge
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:
produces the image:
Where the text is cropped even though it's many pixels from the edge.
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
Where the text is cropped even though it's many pixels from the edge.
Re: convert annotate doesn't go to edge
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
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
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert annotate doesn't go to edge
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
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.Use the Imagick forum for bugs with that API. Note, it is not maintained by the developers of Imagemagick
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:
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.The text is aligned at the edge, but the stroke part is invisible.
Red stroke, text goes to edge:
None stroke, text doesn't go to edge:
White stroke, text goes to edge:
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
This is a bug - but in the inkscape SVG converter. It doesn't show the issue in a newer version of that library.