conversion error by SVG to PNG

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
BerndD

conversion error by SVG to PNG

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: conversion error by SVG to PNG

Post 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.
BerndD

Re: conversion error by SVG to PNG

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: conversion error by SVG to PNG

Post by magick »

We can reproduce the problem and will investigate. Hopefully we'll have a patch in the next point release of ImageMagick.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: conversion error by SVG to PNG

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
BerndD

Re: conversion error by SVG to PNG

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: conversion error by SVG to PNG

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply