SVG rasterizing results in jagged edges

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
immewnity
Posts: 12
Joined: 2011-05-14T14:25:03-07:00
Authentication code: 8675308

SVG rasterizing results in jagged edges

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SVG rasterizing results in jagged edges

Post 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?
immewnity
Posts: 12
Joined: 2011-05-14T14:25:03-07:00
Authentication code: 8675308

Re: SVG rasterizing results in jagged edges

Post 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.
Last edited by immewnity on 2011-06-17T12:38:45-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SVG rasterizing results in jagged edges

Post 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?
immewnity
Posts: 12
Joined: 2011-05-14T14:25:03-07:00
Authentication code: 8675308

Re: SVG rasterizing results in jagged edges

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SVG rasterizing results in jagged edges

Post 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.
immewnity
Posts: 12
Joined: 2011-05-14T14:25:03-07:00
Authentication code: 8675308

Re: SVG rasterizing results in jagged edges

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