Page 1 of 1

SVG rasterizing results in jagged edges

Posted: 2011-06-17T08:36:36-07:00
by immewnity
Hello,

I have ImageMagick set up on my wiki to convert SVG files to PNG (for inline usage), and I am getting a very strange result. The round edges of the SVGs are not, well, being round. They are being very jagged.

Image
(click for original SVG)

Here's the command line that is used (replace $width with width in px, $height with height in px, $input with the SVG, $output with the desired PNG:

Code: Select all

"/usr/local/bin/convert" -density $width -background none -thumbnail $widthx$height\! $input PNG:$output
Does anyone know why this is happening, and if it can be fixed?

Re: SVG rasterizing results in jagged edges

Posted: 2011-06-17T10:09:21-07:00
by fmw42
this works fine to get smooth edges on my IM 6.7.0.8 Q16 Mac OSX tiger:


width=578
height=578
convert -density $width -background none Stormfront_symbol.svg -thumbnail ${width}x${height}! Stormfront_symbol.png

The only issue is that your black has changed to a light purple. Note the input image placement and the {} to avoid the interpreter seeing $widthx and looking for such variable.

Are you using SVG or RSVG?

convert -list format

SVG SVG rw+ Scalable Vector Graphics (RSVG 2.32.1)


What version of IM are you using? If old, perhaps its time to upgrade?

Re: SVG rasterizing results in jagged edges

Posted: 2011-06-17T12:16:28-07:00
by immewnity
fmw42 wrote:this works fine to get smooth edges on my IM 6.7.0.8 Q16 Mac OSX tiger:


width=578
height=578
convert -density $width -background none Stormfront_symbol.svg -thumbnail ${width}x${height}! Stormfront_symbol.png

The only issue is that your black has changed to a light purple. Note the input image placement and the {} to avoid the interpreter seeing $widthx and looking for such variable.

Are you using SVG or RSVG?

convert -list format

SVG SVG rw+ Scalable Vector Graphics (RSVG 2.32.1)


What version of IM are you using? If old, perhaps its time to upgrade?
SVG SVG rw+ Scalable Vector Graphics (XML 2.6.23)

Version: ImageMagick 6.6.9-6 2011-04-26 Q16 http://www.imagemagick.org

I tried using those settings and got an error: "Error creating thumbnail: convert: negative or zero image size `/home/pidginet/public_html/wiki/images/3/3f/Stormfront_-_TCG_set_symbol.svg' @ error/resize.c/ResizeImage/2554."

EDIT: I just tested out the command line with nothing but input and output, and still got the jagged edges. There must be an error with the installation, or the XML rendering just sucks.

Re: SVG rasterizing results in jagged edges

Posted: 2011-06-17T12:37:23-07:00
by fmw42
You might try downloading and installing RSVG and then re-install the latest IM.

Try using my command line, but substitute the exact numbers rather than use variables and see what happens.

What platform are you on?

Re: SVG rasterizing results in jagged edges

Posted: 2011-06-17T12:43:32-07:00
by immewnity
fmw42 wrote:You might try downloading and installing RSVG and then re-install the latest IM.

Try using my command line, but substitute the exact numbers rather than use variables and see what happens.

What platform are you on?
My host says that they won't install RSVG, and they don't allow root access.

I checked the command line, and just simply having input and output still shows the jagged edges. I have a feeling that it is a corrupted installation somewhere.

It's on Linux.

Re: SVG rasterizing results in jagged edges

Posted: 2011-06-17T12:47:50-07:00
by fmw42
My guess is that it is SVG vs RSVG. The latter usually works better. This is what I get from my command using IM with RSVG:


Image


It is also possible that your result is an issue with PNG output as the PNG coder has been improving the PNG function over quite some time now and there were errors at times. So try saving as tif for example and see if that is any better. For me, PNG and TIF results look similar.

Re: SVG rasterizing results in jagged edges

Posted: 2011-06-17T12:57:49-07:00
by immewnity
fmw42 wrote:My guess is that it is SVG vs RSVG. The latter usually works better. This is what I get from my command using IM with RSVG:


Image


It is also possible that your result is an issue with PNG output as the PNG coder has been improving the PNG function over quite some time now and there were errors at times. So try saving as tif for example and see if that is any better. For me, PNG and TIF results look similar.
TIF still gets the jagged border.