IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.

This should ultimately result in three pixels being drawn. But instead you get the single pixel from the point command and two 2x2 rectangles.

As some people in the previous thread explained, this is because apparently ImageMagick does not work with the upper left pixel corners (as SVG and other vector formats do), but instead with full pixels. On the other hand, people in that thread also say that ImageMagick should work exactly like SVG, so this would definitely be a bug then.

Sidenote: according to the current behaviour, to draw a 1x1 rectangle, you'd have to do the following, but the actual result is no output at all:

For those of us who don't use IMagick, it would help if you showed us the output from your code.

Note that when drawing a path from one pixel to an adjacent pixel, both pixels are drawn. But when drawing from one pixel to the same pixel, a "zero-length path", no pixels are drawn. As IM deals with pixels and not really vectors, I would prefer it to draw one pixel, but the decision was made (a long time ago) to stick to the SVG convention.

Your code includes "pathClose", which I suppose is equivalent to SVG "z". So I would expect these pixels to be drawn: 5,4 5,5 4,5 and finally 4,4. Is that what you get?

ImageMagick closely follows the SVG standard. The standard does not permit a rectangle width of 0 but since ImageMagick defines two endpoints for a rectangle, it must represent two identical endpoints as a width of 1. We will add a patch to fix this bug, likely by tomorrow.

If SVG renders a line with identical start and end points as a point, then yes IM should too. Post a short SVG script here that renders a line as a point and we will ensure ImageMagick renders it as a point as well.

Rendering in ImageMagick was written before we starting adopting the SVG rendering model. It is designed for increased quality of rendering using floating point calculations between a point and the corresponding integer pixel on the image grid. SVG likely uses integer calculations on an integer grid for more efficient rendering speed. We have not found time to adopt our rendering algorithm to match the SVG rendering model. Since ImageMagick is open-source, any user can contribute this port. We may revisit a solution ourselves but it could be sometime before we get to it.

I'm meanwhile looking for a solution which works with the current way ImageMagick handles paths, but don't seem to be able to find one. The problem I'm trying to solve: I have an SVG path definition I'm trying to hand over to ImageMagick to draw the same path. This generally works the path points are further apart than one pixel, but when they are exactly one pixel apart, nothing is drawn at all:

I assume the only way right now to solve this would be to make the image twice as large, draw all path coordinates multiplied by two and then shrink the image back to 50% size? Although that will fail again as soon as the path distance is 0.5 pixels.