Page 1 of 1

conversion error by SVG to PNG

Posted: 2007-12-17T05:38:38-07:00
by BerndD
Hello,
I have a usage questions which are too arcane for the normal user list. Hence I post in this section. In my point of view, convert.exe has a bug in the coordinate system for transform vector graphic to pixel graphic. But maybe the developer see this differently. For a normal user the behaviour is not relevant.

I want a SVG (vector graphic) image convert to a PNG (pixel graphic) image. In the SVG image the unit is always px (pixel). The output to the PNG image must be 1:1 without antialias:

convert.exe +antialias input.svg output.png

This produce a unexpected result. Example: A SVG rectangle

Code: Select all

<rect 
	x="0" 
	y="0" 
	width="1" 
	height="1" 
 	style="fill:#000000;fill-opacity:1;stroke:none;  
	id="rect2170" 
  />
should produce a black pixel on the upper, left edge in the PNG image. But the result is a 2x2 pixel rectangle. The reason is, that the zero point of the destination coordinate system is not on the middle of the upper, left PNG image pixel. Rather it is at the right, bottom edge of the upper, left pixel. If I try

Code: Select all

<rect 
	x="-0.5" 
	y="-0.5" 
	width="1" 
	height="1" 
 	style="fill:#000000;fill-opacity:1;stroke:none;  
	id="rect2170" 
  />
then it's work correct. But I can not change the input image at the real application, so I need a bug fix or work around for a correct output.

I have try to use

convert.exe +antialias input.svg -distort SRT '0,0 1 0 -0.5, -0.5' output.png

This bring the error message: unrecognized option `-distort'. I use imagemagick 6.3.4-q8 (Windows XP binary). Why this? Is distort SRT a solution for my problem or work this only from pixel image to pixel image?

If no user solution available, I would be happy, if some developer can help me, to make a source code patch.

Many thanks in advance
Bernd

Re: conversion error by SVG to PNG

Posted: 2007-12-17T09:17:12-07:00
by magick
Download ImageMagick-6.3.7-5, the latest release. If the problem persists, post a SVG file that illustrates the problem and that will parse (what you posted does not parse), and we will investigate and come up with a solution.

Re: conversion error by SVG to PNG

Posted: 2007-12-17T10:43:59-07:00
by BerndD
Hello Magick,
the problem persists in the latest release too. How can I post a file here? :?
I has upload a zip archiv with a input.svg, output.png and test.bat file to my server:
http://www.aha-poster.de/svg2png_test.zip

Re: conversion error by SVG to PNG

Posted: 2007-12-17T11:16:42-07:00
by magick
We can reproduce the problem and will investigate. Hopefully we'll have a patch in the next point release of ImageMagick.

Re: conversion error by SVG to PNG

Posted: 2007-12-17T18:07:00-07:00
by anthony
BerndD wrote: This bring the error message: unrecognized option `-distort'. I use imagemagick 6.3.4-q8 (Windows XP binary). Why this?
The -distort operator was a recent addition (by me), and one that is still being improved and developed. The underlying functions is about to undergo more work soon. It became practical for users to use in IM v6.3.6.

Re: conversion error by SVG to PNG

Posted: 2007-12-18T01:45:26-07:00
by BerndD
@Magick: Thanks! Please let me know if I can help. A solution is very important for me.

@Anthony: I see. It would be helpful if each option in the documentation has specified the initial version for it.
I will try the -distort option with the latest release once again. But I think this operator work internal always with a pixel image as input, therefore it can not correct the conversion error.

Re: conversion error by SVG to PNG

Posted: 2007-12-18T16:30:48-07:00
by anthony
I have tried to mark when options are added or modified in IM examples. Look for the WARNING symbol Image OR in the introduction to a specific option.