Resampling embedded raster images in SVG

image manipulationresamplingsvg

I have a batch of SVG files with embedded, high-res PNG images. The PNG files have been resized considerably smaller (via transform, matrix, etc). What is the best way to resample these embedded images in place? The goal is to get smaller, faster-loading SVG files.

Just to clarify some terminology (emphasis added):

Resampling changes the total number of pixels in the image…

When you resize an image and do not resample it, you change the size of the image without changing the amount of data…

Clearly, I am only resizing the images right now.

I have toyed with trying to automate it using ImageMagick, but keeping the image proportions is not entirely trivial. Is there a simple Inkscape hack? Or something else I'm overlooking?

Best Answer

Inkscape does in fact have a resample option (it may be part of ImageMagick). These options are available from the Extensions -> Raster menu.

To resample items in your image:

  1. Embed the images via Extensions -> Images -> Embed Images...
  2. Select the embedded image(s)
  3. Resample via Extensions -> Raster -> Resample

enter image description here

  1. Decrease the Width and Height values to the lowest acceptable values
  2. Apply and Close

This method will work well during the authoring process. I am still working on a way to automate this and will update this post if I find a good method.

Related Question