How to resize a vector image?
February 24, 2010 7:19 PM   Subscribe

How do I resize a vector image with the command line?

I'm trying to repeatedly resize a very simple vector image (eps, svg, pdf, whatever) on the OS X command-line with a script. The images will be resized at 50% to about 3000%.

My immediate response was to use imagemagick, but it turns out that imagemagick doesn't preserve vector formats, but just wraps a vector format around a rasterized image.

Does anybody have any suggestions? Thanks!
posted by suedehead to Computers & Internet (8 answers total)
 
A vector image doesn't have a size. Its size is defined when it's rasterized for display or printing.
posted by odinsdream at 7:45 PM on February 24, 2010


SVG images can have sizes defined: http://www.w3.org/TR/SVG/coords.html#UnitIdentifiers

If your images have the height and width defined in the outer tag like this example, then maybe you can just modify it directly.
posted by demiurge at 7:54 PM on February 24, 2010


Vector graphics have a size. However they don't have a size of pixels but rather abstract coordinates. For processing SVG, it's a declarative XML format and you can use XSLT to do basic transforms (or perhaps regex if your input is amenable). EPS and PDF are procedural so resizing them won't make much sense.
posted by pwnguin at 7:56 PM on February 24, 2010


Here's the same question asked on the Inkscape forum.

I tried this suggestion, and it worked with an Inkscape-created SVG.

Note that you also need to edit the width and height attributes in the <svg> tag to change the canvas size.

This is a few minutes of work in a scripting language to automate.
posted by qxntpqbbbqxl at 8:07 PM on February 24, 2010


I've been using librsvg (it comes with a program called rsvg-convert) for some vector work I've been doing, and it has been very simple to use. I believe it does resizing.
posted by !Jim at 9:17 PM on February 24, 2010


Yeah, I know vector images don't have a size -- the reason I need to 'resize' them is because I need each of them to be specifically, proportionately sized in relation to a raster image. A few hundred images, in fact. I'd like to automate that so that the rest of the process is painless importing in Indesign.

It turns out that demiurge's method was the most convenient -- a simple 'sed' search-and-replace command was enough to let me modify and resize each SVG image. Thanks!
posted by suedehead at 9:25 PM on February 24, 2010


Then you should mark it as a "best answer" to reward demiurge for taking the time to offer it to you.
posted by Chocolate Pickle at 9:38 PM on February 24, 2010


Yes yes yes, just forgot to click the button.
posted by suedehead at 1:34 AM on February 25, 2010


« Older Have an IR Tranceiver that wor...   |  When did the cultural norm of ... Newer »
This thread is closed to new comments.