0

I have imported several photos in an Inkscape file and then reduced them manually inside my document. In order to get a lighter Inkscape document size, is there a way to save the document by taking into account the reduced images sizes? Or do I have to reduce my images before importing them into Inkscape?

I remember such a function in Microsoft Office Word, where it was possible to save only the real size of images clipped inside the Word document.

I hope this is clear enough... Many thanks for help and advices in advance.

2

You need to modify the image with an external editor and re-embed it.

When you embed a raster image in Inkscape, it embeds it in the href of the image using a data URI:

<svg:image xlink:href="data:image/jpeg;base64,[...]"/>

When you resize an embedded image in Inkscape, what it does it is changes the height and width attributes of the <svg:image>; it does not change the data URI, meaning the image itself is not changed. You can see this yourself by looking at the XML view in Inkscape and comparing the data URI before and after resizing the image. In most cases, this is desirable behavior, since Inkscape is not really the right tool for modifying raster graphics (always use the right tool!).

To extract the embedded image, select it and use Extensions > Images > Extract Image. If you need to extract multiple images from an SVG file, you might want to look at this answer as well.

  • Thanks @Scribblemacher! I thought it would probably not be possible, and I totally agree with your 'always use the right tool' statement. In the meantime, I used Gimp to batch-resize my pictures ([BIMP plugin: alessandrofrancesconi.it/projects/bimp) before embedding them again. – wiltomap Jul 24 '15 at 11:53
  • @wiltomap: Note that, if you accepted an answer, you usually should also upvote it. If not, explain why you do not consider it worthy your upvote. – Wrzlprmft Jul 25 '15 at 10:04
  • Just did it. Didn't know that, sorry... – wiltomap Jul 27 '15 at 6:14
1

Inkscape can export scaled bitmaps. Besides resizing, the resulting graphics can take into account added enhancements such as clipping, masking, gradients, and filter effects. If density and dimension are final, the original graphics and part of their elaboration can be replaced with the corresponding exported bitmaps. That makes it possible to continue working on a document using less memory and less processing power.

Each image has to be arranged manually at least once. Create an invisible rectangle around a raster object and export the visible area to a file. At 90 dpi, each rectangle's bitmap size matches its export area size in pixels. The exported file can then be reimported. Repetitions can be made easier. For example, you can put all invisible rectangles in a layer named "exports" and hit Ctrl-A to select them, then Check "Batch export N selected objects". The corresponding visible objects can stay in a different layer. Yet another layer can contain links to the exported bitmaps. Batch export silently overwrites files, so they are automatically updated if you keep reimported image externally linked (rather than embedded). That way you can work on a single document by switching layers visibility and lock status.

Instead, if the intent is just to obtain a reasonably sized, shareable document, it is much easier to save a copy as PDF and optimize it using an external tool, e.g. Ghostscript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.