ImageMagick dash array bug…

I’ve been using ImageMagick (a great image library / toolset by the way) for some time now. Recently, I ran across a bug in the library when trying to draw straight dashed lines. You can get the details on the ImageMagick forum itself.

As that forum doesn’t allow posting of images (as far as I can tell) - I’m posting the error condition and the output of it here in hopes to aid developers more quickly find a fix for it :) The problem is when I use certain dash array combinations and then draw lines starting from the left most pixel - an extra diagonal line is drawn from (0,0) to the end of the line I wanted drawn. Let me illustrate:

convert -size 20×20 xc:skyblue -fill white -stroke black \
-draw “stroke-dasharray 0.5 1.5 path ‘M 3,5 L 16,5 ‘ ” \
-draw “stroke-dasharray 0.5 1.5 path ‘M 3,10 L 16,10 ‘ ” \
-draw “stroke-dasharray 0.5 1.5 path ‘M 3,15 L 16,15 ‘ ” \
-scale 800% draw_dasharrays.gif

The above ImageMagick command creates the following gif image:

Good Dashes

Now, if we start the third line at column 0, we get an extra
undesired diagonal line from (0,0) to the end of the third line:
convert -size 20x20 xc:skyblue -fill white -stroke black
-draw "stroke-dasharray 0.5 1.5 path 'M 3,5  L 16,5  ' "
-draw "stroke-dasharray 0.5 1.5 path 'M 3,10 L 16,10 ' "
-draw "stroke-dasharray 0.5 1.5 path 'M 0,15 L 16,15 ' "
-scale 800% draw_dasharrays.gif

Bad Dashes

Leave a Comment

Name (required)

Mail (will not be published) (required)

Website

Comment