Page 1 of 1

SVG composites: are SVGs not really scalable in ImageMagick?

Posted: 2006-11-17T19:41:18-07:00
by rschmitty
Hello all,

When ImageMagick takes a svg file does it convert to something of its own?

Using the following command

composite -compose atop -background none -geometry +200+200 red_circle.svg helloWorld.jpg output.jpg

The red circle in the output looks crisp and clear as expected, however, when we add the -resize flag...

composite -compose atop -background none -geometry +200+200 red_circle.svg -resize 1000x1000 helloWorld.jpg output.jpg

The circle appears to be rasterized with visible pixelation.


Any ideas? or am I missing a step here? Seems like theres gotta be a way for IM to 'open' the svg at a certain size % and I'm just missing the flag


TIA

-Rick

Posted: 2006-11-17T22:16:24-07:00
by magick
Use -density rather than -resize for vector graphic formats such as SVG.

Posted: 2006-11-19T19:12:41-07:00
by anthony
The reason for the 'pixelation' is that the vector image was first converted to a raster image, then it was resized. By setting -density BEFORE reading in the SVG image you specy the number of pixels per inch the SVG draws. As such using a -density 600 on a small 1 inch circle will generate a perfect 600 pixel circle, when the SVG is converted to a raster image.

For more details see
A word about Vector Image formats
http://www.cit.gu.edu.au/~anthony/graph ... ts/#vector

As for your first question.
When ImageMagick takes a svg file does it convert to something of its own?
Yes IM will use a internal vector format as a intermediate step to converting the image to a raster format. It is talked about in IM Examples as this language is often a lot simpler and easier to understand than SVG format.
However IM can also use an extenal delegate to do the conversion from SVG to a raster, either using an extrnel delegate program like "rsvg" or the gnome gtk-2 SVG library, that has since become common.
I am however not sure how you can telll what method IM uses to do this, or what the internals are as I have not looked. I have only seen tantalizing clues as to what is happening due to error messages in some of my tests, and the 'deletage' list.

Cristy, can you enlighten use further on the current SVG coding status within IM?

Posted: 2006-11-20T09:32:09-07:00
by magick
ImageMagick checks for an appropriate RSVG delegate library at build time. If found, ImageMagick uses it to render SVG. If not, it converts SVG to MVG and uses the internal MVG renderer to convert the vector graphics to pixels.

Posted: 2006-11-20T20:15:14-07:00
by anthony
Thanks. I have updated the appropriate parts of the 'Drawing' section of the IM examples, with that qualification.