SVG composites: are SVGs not really scalable in ImageMagick?

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
rschmitty

SVG composites: are SVGs not really scalable in ImageMagick?

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

Post by magick »

Use -density rather than -resize for vector graphic formats such as SVG.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post 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?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

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

Post by anthony »

Thanks. I have updated the appropriate parts of the 'Drawing' section of the IM examples, with that qualification.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply