viewBox x and y not used at converting svg to png

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
Alex Dobusch
Posts: 10
Joined: 2011-10-11T07:50:11-07:00
Authentication code: 8675308

viewBox x and y not used at converting svg to png

Post by Alex Dobusch »

Hello

I'm using the latest subversion trunk (rev. 6100).

In my svg file I declared a viewBox with x and y coordinates, like 'viewBox="50 50 150 150"'.
It seems that these coordinates were not used to convert the svg, only the width and height of the viewBox.
After debugging the code I found the solution in the file 'coders\svg.c'
At line 2167 change

Code: Select all

          double
            sx,
            sy;
to

Code: Select all

          double
            sx,
            sy,
            tx,
            ty;
and at line 2180 change

Code: Select all

          (void) FormatLocaleFile(svg_info->file,"affine %g 0 0 %g 0.0 0.0\n",
            sx,sy);
to

Code: Select all

          tx= svg_info->view_box.x != 0.0 ? (double) sx*-svg_info->view_box.x : 0.0;
          ty= svg_info->view_box.y != 0.0 ? (double) sy*-svg_info->view_box.y : 0.0;
          (void) FormatLocaleFile(svg_info->file,"affine %g 0 0 %g %g %g\n",
            sx,sy,tx,ty);
Now it uses the x and y coordinates from the viewBox.

Alex
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: viewBox x and y not used at converting svg to png

Post by magick »

Thanks for the problem report and patch. We'll get it into the subversion trunk by sometime tomorrow.
Post Reply