SVG image preserveAspectRatio support or work-around

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
neilo

SVG image preserveAspectRatio support or work-around

Post by neilo »

I have a small SVG file which defines how to create a thumbnail from an arbitrary image (I use XSL to fill in the filename) and then I planned on using the command-line convert utility (ImageMagick) against this to make it a JPG. The SVG views fine in FireFox but the JPEG created by ImageMagick appears to disregard preserveAspectRatio in svg:image.

Here is my SVG, you can try it with any ol' source image:

Code: Select all

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="125" height="125" version="1.1"
     xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink">
	<image xlink:href="full-size-image.jpg" x="0" y="0"
		width="125" height="125" preserveAspectRatio="xMidYMin slice" />
	<rect x="0" y="0" width="125" height="125" rx="4" ry="4"
		stroke="white" stroke-width="3" fill="none" />
</svg>
Is there no support for this in ImageMagick, or it's perhaps a bug or in the works? I wasn't sure where to post this particular issue, so maybe it belongs in the developer forum. Any wizards out there have suggestions or work-arounds?

Thanks in advance!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: SVG image preserveAspectRatio support or work-around

Post by magick »

Type
  • identify -list format
and make sure RSVG is associated with the SVG tag. We converted your SVG script with ImageMagick-6.6.2-4 and it produced the expected results.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SVG image preserveAspectRatio support or work-around

Post by fmw42 »

Do you have rsvg delegate library installed? type

convert -list configure

and look at the line DELEGATES and see if rsvg is listed. If not, then you need to install that and then reinstall IM from source.
Post Reply