Bug With stroke-linecap round and stroke-dasharray

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
viarun
Posts: 10
Joined: 2010-12-20T11:57:07-07:00
Authentication code: 8675308

Bug With stroke-linecap round and stroke-dasharray

Post by viarun »

I'm having an issue with drawing lines, arcs, rectangles, with dotted lines.

I have tried different versions of imagemagick, back to 6.7.7, and while the bug works a little differently, it appears in older versions as well. The only difference is at what point the round linecaps quit being drawn.

Using the latest version (6.9.0), built from source, on a Debian machine, I get these results:

command: convert -size 220x220 xc:black -draw "fill none stroke-linecap round stroke-width 4 stroke green stroke-dasharray 1,10 arc 10,10 200,200 0,360" out1.png

resulting image: Image

You can see that the round linecaps aren't drawn in the lower right of the image.

The bug does seem to manifest itself in the lower areas of an image. Here's a command where I draw several lines, and they look correct until I draw 128 pixels down from the top. If you change that draw command so that it draws from 10,127 to 200,127 (instead of 10,128 200,128), the round linecaps work fine.

command: convert -size 220x220 xc:black -draw "fill none stroke-linecap round stroke-width 4 stroke green stroke-dasharray 1,10 line 10,10 200,10 line 10,100 200,100 line 10,120 200,120 stroke red line 10,128 200,128 line 10,180 200,180 " out2.png

resulting image: Image

I did manually overlay the two images above, and it's interesting that the bug seems to start at what looks to be the same x/y point (128 from the left,128 from the top)

Image

I would guess that this bug is somewhere in magick/draw.c, but my C skills are pretty rusty, and I didn't see anything obvious.

Any help would be appreciated.
viarun
Posts: 10
Joined: 2010-12-20T11:57:07-07:00
Authentication code: 8675308

Re: Bug With stroke-linecap round and stroke-dasharray

Post by viarun »

Here's the lines image when drawn with IM 6.7.7 instead of 6.9.0

command: convert -size 220x220 xc:black -draw "fill none stroke-linecap round stroke-width 4 stroke green stroke-dasharray 1,10 line 10,10 200,10 line 10,100 200,100 line 10,120 200,120 stroke red line 10,128 200,128 line 10,180 200,180 " out2.png


resulting image: Image

Similar issue, just starts sooner. Also, the first line looks like diamonds instead of circles, not sure what that is.
viarun
Posts: 10
Joined: 2010-12-20T11:57:07-07:00
Authentication code: 8675308

Re: Bug With stroke-linecap round and stroke-dasharray

Post by viarun »

I assume this post isn't getting much attention as this type of bug is complex to diagnose?

If so, I understand. Just wanted to make sure it wasn't something else, like "that doesn't look like a bug".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Bug With stroke-linecap round and stroke-dasharray

Post by fmw42 »

I can pretty much confirm your results. Though I know little about line-caps and such. I tried separating your command into multiple draw commands, but get pretty much the same as you. My result1 has only 1 bright right spot on the left side where yours has two.

Code: Select all

convert -size 220x220 xc:black \
-draw "fill none stroke-linecap round stroke-width 4 stroke green stroke-dasharray 1,10 line 10,10 200,10" \
-draw "fill none stroke-linecap round stroke-width 4 stroke green stroke-dasharray 1,10 line 10,100 200,100" \
-draw "fill none stroke-linecap round stroke-width 4 stroke green stroke-dasharray 1,10 line 10,120 200,120" \
-draw "fill none stroke-linecap round stroke-width 4 stroke red stroke-dasharray 1,10 line 10,128 200,128" \
-draw "fill none stroke-linecap round stroke-width 4 stroke red stroke-dasharray 1,10 line 10,180 200,180" out2b.png

Code: Select all

im6788 convert -size 220x220 xc:black \
-draw "fill none stroke-linecap round stroke-width 4 stroke green stroke-dasharray 1,10 line 10,10 200,10" \
-draw "fill none stroke-linecap round stroke-width 4 stroke green stroke-dasharray 1,10 line 10,100 200,100" \
-draw "fill none stroke-linecap round stroke-width 4 stroke green stroke-dasharray 1,10 line 10,120 200,120" \
-draw "fill none stroke-linecap round stroke-width 4 stroke red stroke-dasharray 1,10 line 10,128 200,128" \
-draw "fill none stroke-linecap round stroke-width 4 stroke red stroke-dasharray 1,10 line 10,180 200,180" out1b.png
t9mike
Posts: 4
Joined: 2015-03-18T10:02:37-07:00
Authentication code: 6789

Re: Bug With stroke-linecap round and stroke-dasharray

Post by t9mike »

I think I am seeing the same issue. This:

Code: Select all

convert -size 220x220 xc: -draw 'fill none stroke-linecap round
    stroke-width 20 stroke red ellipse 110,110 100,100 25,345' test.png
yields broken endcap:
Image
But this:

Code: Select all

convert -size 220x220 xc: -draw 'fill none stroke-linecap round
    stroke-width 20 stroke red ellipse 110,110 100,100 95,345' test.png
is OK:
Image
Post Reply