Omitted elliptical arc commands not working

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
rmagick
Posts: 245
Joined: 2006-03-16T17:30:48-07:00
Location: Durham, NC, USA

Omitted elliptical arc commands not working

Post by rmagick »

This is ImageMagick 6.5.4-8 on Ubuntu.

I'm trying to reproduce this SVG example (http://www.w3.org/TR/SVG11/painting.html#FillProperties) using MagickWand
Image
Using the MagickWand drawing API I created this MVG file:

Code: Select all

push graphic-context
 scale 0.355,0.355
 push graphic-context
  fill-rule 'NonZero'
  stroke-width 3
  stroke '#000000000000'
  fill '#FFFF00000000'
  path 'M600,81A107,107 0 0 1 600,295 107,107 0 0 1 600,81ZM600,139A49,49 0 0 1 600,237 49,49 0 0 1 600,139Z'
 pop graphic-context
pop graphic-context
I use this command to render it:

Code: Select all

convert -size 426x142 test.mvg test.png
Here's the output:
Image
I see that MagickWand has omitted the A when the 2nd A immediately follows an A. I understand that this is permitted by the SVG standard.

If I manually edit the MVG file to add the omitted A's, however, the result is correct.

Code: Select all

  path 'M600,81A107,107 0 0 1 600,295 A107,107 0 0 1 600,81ZM600,139A49,49 0 0 1 600,237 A49,49 0 0 1 600,139Z'
Image
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Omitted elliptical arc commands not working

Post by magick »

Using the MagickWand drawing API I created this MVG file
We'll need a working program that uses the MagickWand drawing API to produce the path that is failing. We need to determine if the problem is in your code or the MagickWand drawing API.
rmagick
Posts: 245
Joined: 2006-03-16T17:30:48-07:00
Location: Durham, NC, USA

Re: Omitted elliptical arc commands not working

Post by rmagick »

Sure thing. Here you go. Please let me know if you need anything else.

Code: Select all

/*
 *  gcc `MagickWand-config --cflags --cppflags` -o arcbug arcbug.c `MagickWand-config --ldflags --libs`
 */
#include <stdio.h>
#include <stdlib.h>
#include <wand/MagickWand.h>

int main(int argc, char **argv)
{
    MagickWand *wand;
    DrawingWand *drawing;
    PixelWand *red, *white;

    MagickWandGenesis();

    red = NewPixelWand();
    PixelSetColor(red, "red");
    white = NewPixelWand();
    PixelSetColor(white, "white");

    drawing = NewDrawingWand();

    DrawSetFillColor(drawing, red);
    DrawPathStart(drawing);
    DrawPathMoveToAbsolute(drawing, 600.0, 81.0);
    DrawPathEllipticArcAbsolute(drawing, 107.0, 107.0, 0.0, MagickFalse, MagickTrue, 600.0, 295.0);
    DrawPathEllipticArcAbsolute(drawing, 107.0, 107.0, 0.0, MagickFalse, MagickTrue, 600.0, 81.0);
    DrawPathClose(drawing);

    DrawPathMoveToAbsolute(drawing, 600.0, 139.0);
    DrawPathEllipticArcAbsolute(drawing, 49.0, 49.0, 0.0, MagickFalse, MagickTrue, 600.0, 237.0);
    DrawPathEllipticArcAbsolute(drawing, 49.0, 49.0, 0.0, MagickFalse, MagickTrue, 600.0, 139.0);
    DrawPathClose(drawing);
    DrawPathFinish(drawing);

    wand = NewMagickWand();
    MagickNewImage(wand, 1200, 400, white);
    MagickDrawImage(wand, drawing);
    MagickWriteImage(wand, "arcbug.png");
    MagickWriteImage(wand, "arcbug.mvg");

    DestroyDrawingWand(drawing);
    DestroyMagickWand(wand);
    DestroyPixelWand(red);
    DestroyPixelWand(white);

    MagickWandTerminus();
}
Here's the arcbug.mvg file:

Code: Select all

fill '#FFFF00000000'
path 'M600,81A107,107 0 0 1 600,295 107,107 0 0 1 600,81ZM600,139
A49,49 0 0 1 600,237 49,49 0 0 1 600,139Z'
For comparision, here's the path element from the SVG example:

Code: Select all

<path d="M 600,81 A 107,107 0 0,1 600,295 A 107,107 0 0,1 600,81 z
             M 600,139 A 49,49 0 0,1 600,237 A 49,49 0 0,1 600,139 z" />
Here's the arcbug.png file:
Image
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Omitted elliptical arc commands not working

Post by magick »

We can reproduce the problem you reported and have a patch in the Subversion trunk available sometime tomorrow. The patch will also be in the next point release of ImageMagick. Thanks.
Post Reply