Mobile app version of vmapp.org
Login or Join
Mendez620

: Is there an automated way to remove cropped regions of embedded images in order to optimize the size of an Inkscape SVG file? I am preparing some figures for a scientific publication using

@Mendez620

Posted in: #Crop #Embedded #Inkscape #Optimization #Svg

I am preparing some figures for a scientific publication using Inkscape. These figures are SVGs containing embedded bitmap images that are quite large, but only a small rectangular clipped region of each image is actually displayed. An example image is shown below (the SVG itself is available here):



These images will ultimately be embedded into a PDF document. In order to keep the document file size reasonably small, I'm looking for a way to reduce the overall file size by "throwing out" pixels that fall outside of the clipping rectangles.

I could do this by manually cropping each image in an external editor, then re-importing it into the SVG, repositioning it, scaling it etc. to match the current clip box. This is quite tedious, though. I'd ideally like to be able to convert quickly and easily between a "working copy", where I can edit the clipping rectangles, and an "optimized copy" that only contains the pixels that I actually want to display.

Is there an automated way to do this using Inkscape or some other tool? I'd also be interested in any potential solutions that operate on PDF or EPS files.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Mendez620

2 Comments

Sorted by latest first Latest Oldest Best

 

@Murray976

1) Bitmap copy workaround:


Select the bitmap image with the clipping mask and press ALT + B (create a bitmap copy).
Delete the original image.


The resolution of the bitmap copy can be set in the Edit > Preferences > Bitmaps menu.

2) Filter workaround:


Apply dummy filters to the clipped bitmap images (e.g. Filters > Fill and Transparency > Blend with default options)
Set the Rasterize filter effects checkbox in the PDF export window.


3) Embed and crop extension:
cellbio.emory.edu/bnanes/svg-embed-and-crop/
The biggest issue of the extension is that it does not work if the raster image is already embedded (and not linked to a file).

10% popularity Vote Up Vote Down


 

@Chiappetta793

For the use case you describe, I would probably recommend investigating the LaTex document markup language.
en.wikipedia.org/wiki/LaTeX
Essentially, you write markup to give semantic meaning to the content of your document. This semantic markup can then be styled and rendered into a PDF file for digital distribution.

I recommend this for you as you can use LaTex macros such as graphicx and/or adjustbox to specifiy a crop of an included image. When the final document is rendered out, LaTex will only included the uncropped sections of the image in the file size.

Here's a good SE thread with lots of information on learning LaTex: tex.stackexchange.com/questions/11/what-are-good-learning-resources-for-a-latex-beginner

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme