5

When using Inkscape to create many pictures with common elements across them, I tend to copy the first SVG file I have created as many times as I need pictures, and then edit the copies. If I reuse files across projects, it can result in a file being copied and modified tens to hundreds of files.

I have recently realized that the latest copies have a size between 29 and 60 MB, slowing my computer down significatively. My pictures are very simple, nothing that would normally go over 1 MB in size.

As an experiment, I copied the entire content of one of the latest files into a new Inkscape file. I am certain that I have copied the content of the file entirely (I have only one layer and I used the "Select All" option). The new file has a size of 102,2 KB. This would indicate that about 30 MB of data per file is irrelevant to me.

What could be the cause of this size difference ? Is there a way to reduce the size of a file without having to copy the content into a new file ?

I am using Inkscape 0.48.4 on Debian Unstable.

Thanks for any input you might be able to provide !

4
  • Why don't you just change the image container that is more compressed. 30MB files shouldn't slow down your computer.
    – Ramhound
    May 30, 2014 at 15:28
  • How do you copy?
    – Wrzlprmft
    May 30, 2014 at 21:10
  • I just use the system "cp" command.
    – Keyran
    May 31, 2014 at 7:57
  • @Ramhound 30 MB files do slow down my computer when opened with Inkscape. It's quite an old laptop. I don't really understand your other comment about changing the image container. I can get SVG files of reasonable size for the same content, so I don't think the format is the culprit here. I'd be grateful if you could explain where I'm mistaken.
    – Keyran
    May 31, 2014 at 8:06

2 Answers 2

4

It sounds like Inkscape amasses some metadata while you are working, which is not deleted because of a bug or because you are using some methods in an unexpected way or more often than expected. You can try to find out what is causing your problem by looking at the raw SVG file (in a regular text editor or Inkscape’s XML Editor) and trying to make sense of the content.

Also, if you are using some operation rather excessively, this is a good guess for what enlarges your files. In particular, you should be careful with anything that uses external files.

In general, I know of three ways to remove spurious information from SVG files:

  • Use Inkscape’s Vacuum Defs. This deletes some information, which Inkscape has guessed that you might want to use again such as custom gradients.
  • Save the SVG file as Plain SVG instead of Inkscape SVG. This makes some objects (such as object connectors) converted to a more primitive object type, as they are not contained in the SVG standard (see also here).
  • Write a script (e.g., for Sed) that purges whatever information you want to get rid of. As SVGs are XML-based, this is not as tedious as it sounds.
6
  • I guess saving as plain SVG will increase file size - dedicated formats for complex structures are usually more optimized than results of attempts to recreate them with limited features available, which is what saving as plain SVG effectively does.
    – gronostaj
    Jun 2, 2014 at 9:38
  • @gronostaj: While you are correct that this effect acts incremental on the file size, it can usually not counteract the effect of Inkscape’s metadata being removed – especially if my assumption is correct and the metadata went out of scale for some reason. I would even guess that only carefully constructed examples are smaller when saved as an Inkscape SVG.
    – Wrzlprmft
    Jun 2, 2014 at 10:15
  • I've tried it out on a 54.1 MB file. Vacuum Defs brings it down to 129.2 kB, saving it as plain SVG reduces the size again by about 10 kB. I don't know exactly what I am doing to create this amount of metadata, but I know where to look. Thanks !
    – Keyran
    Jun 2, 2014 at 15:35
  • I've taken a look at the diff between the vacuumed file and the original, and you were right, it's mostly gradients : 980 <radialGradient> tags, 495 <linearGradient> tags, plus 929 <path> tags. I can't possibly have created that many gradients, so I still have to find out how they proliferate between copies.
    – Keyran
    Jun 2, 2014 at 15:59
  • WORKED FOR ME TOO! I also had this problem. I was creating an icon for libreoffice-main based on other libreoffice icons -writer, -calc, etc. I both imported these other icons and copy & pasted parts of them into the new icon file. The result was 11.7 MB, while the originals were 144K, 536K, 468K, 624K & 1.3M. File->Vacuum Defs worked for me also reducing the filesize down to 965.6K and then saving as plain SVG resulted in 828.2K Cheers :-) Dec 10, 2014 at 11:12
1

I believe it might have something to do with <image xlink:href=data:image/png;base64..., which is to my knowledge the encoding of an image. I've recently been working with a file that consists of simple paths and an image; the encoding of the image is nearly 835,000 characters long, whereas everything else is only an additional 120,000 characters.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .