Search code examples
phpimagemagickimagick

ImageMagick dashed rectangle incorrectly rendered


When trying to draw a dashed rectangle with ImageMagick using the following command:

convert -size 300x300 xc:skyblue -fill white -stroke black \
-draw "stroke-width 3 stroke-dasharray 10 10 rectangle 50,50 250,250" draw_rect.gif

I get the following image, clearly wrong (note the "z" shapes):

enter image description here

No matter what I try (it happens also with paths, with different line caps and joins, stroke widths, dash arrays, colors, transparent fill,...) I get these strange artifacts.

Version is ImageMagick 6.9.10-68 Q16 aarch64 2021-02-02 (ARM), but I tried also with an x86 server ImageMagick 6.9.10-68 Q16 x86_64 2021-02-03 and got the same result.

Is this an ImageMagick limitation? a bug? If so, I can't believe a library so mature could behave so weird.


Solution

  • Using IM 6.9.12.73, I get the following result with your following command.

    convert -size 300x300 xc:skyblue -fill white -stroke black -draw "stroke-width 3 stroke-dasharray 10 10 rectangle 50,50 250,250" draw_rect.gif
    

    enter image description here

    Likely, your old version of Imagemagick had a bug. You should upgrade if you can.