Page 1 of 1
Conversion of SVG to other formats does not correctly work
Posted: 2018-07-26T05:09:09-07:00
by alex.schneider
Conversion of SVG images to other formats does not always correctly work.
My ImageMagick Version is:
Code: Select all
Version: ImageMagick 7.0.8-8 Q16 x86_64 2018-07-26 https://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: https://www.imagemagick.org/script/license.php
Features:
Delegates (built-in): freetype jng jpeg lcms png webp xml
The commands I've tried are very simple:
and
test.svg:
https://drive.google.com/file/d/1j5jdjF ... sp=sharing
convert.png
https://drive.google.com/file/d/1jLZaLW ... sp=sharing
magick.png
https://drive.google.com/file/d/1xnlw5q ... sp=sharing
Re: Conversion of SVG to other formats does not correctly work
Posted: 2018-07-26T06:00:06-07:00
by snibgo
It seems to work fine with IM v7.0.7-28 and Inkscape 0.91.
I guess you don't use Inkscape as the delegate. I suggest you install it.
Re: Conversion of SVG to other formats does not correctly work
Posted: 2018-07-26T07:19:53-07:00
by canavan
We're indeed using the "builtin" SVG coder, and not rsvg or Inkscape, since those have way too many dependencies for our taste.
Actually the Image as rendered by ImageMagick 7.0.8 is a marked improvement over 7.0.7, in that the `<use transform=` statements have an effect at all, it's just that the coordinates are not correctly computed, they seem to be off by 45°. Previously, there was only a single black drop and one crown.
Re: Conversion of SVG to other formats does not correctly work
Posted: 2018-07-27T07:12:20-07:00
by canavan
The cause here is apparently that the builtin svg renderer assumes that x==y if y is not specified in e.g.
If I expand that to
the image looks perfectly fine.
According to
https://developer.mozilla.org/en-US/doc ... /transform
The translate(<x> [<y>]) transform function specifies a translation by x and y. If y is not provided, it is assumed to be zero.
Proposed Patch:
Code: Select all
diff --git a/coders/svg.c b/coders/svg.c
index 4505bb483..5d5f3452f 100644
--- a/coders/svg.c
+++ b/coders/svg.c
@@ -2222,7 +2222,7 @@ static void SVGStartElement(void *context,const xmlChar *name,
(*p == ','))
break;
affine.tx=GetUserSpaceCoordinateValue(svg_info,1,value);
- affine.ty=affine.tx;
+ affine.ty=0;
if (*p != '\0')
affine.ty=GetUserSpaceCoordinateValue(svg_info,-1,
p+1);
The same change may be necessary in line 1835 of coders/svg.c
Re: Conversion of SVG to other formats does not correctly work
Posted: 2018-07-27T08:18:09-07:00
by snibgo
Many thanks for your diagnosis. I hope a developer will apply your patch(es).
Re: Conversion of SVG to other formats does not correctly work
Posted: 2018-07-27T08:57:04-07:00
by magick
Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @
https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @
http://www.imagemagick.org/download/beta/ by sometime tomorrow.
Re: Conversion of SVG to other formats does not correctly work
Posted: 2018-07-31T07:53:08-07:00
by canavan
I can confirm that the current beta fixes this problem for us. Thanks.