1

I have a chart in a PDF file that I aim to convert to an SVG file via, e.g., Inkscape. My issue is that the figure itself contains thousands of objects (i.e., individual points), which leads to a huge file size both for the PDF and to an even greater extent for the SVG file. The graph itself is very dense, which means that there are many points that are completely under the hood and are overlaid by other points.

Is there any way to remove these hidden points? Or are there other ways to get the file size down?

It seems that both Path Combine and Path Union work somewhat along these lines, but the problem is that the entire chart then consists only of "blue" dots.

Exemplary chart:

example

4
  • Hi. What file size is the SVG? What do you consider "huge"? What would be an acceptable file size for you?
    – Billy Kerr
    Jul 1, 2023 at 12:06
  • For expositional purposes the exemplary chart has a PDF file size of 63KB. However, my real file is about factor 10 with around 6MB with the SVG being around 18MB. The aim is to get the file size as small as possible for multiple reasons: (i) the charts need to be embeeded in a Word document, (ii) it takes some time to render the charts now which is annoying for the readers etc. The real chart looks more like such a beeswarm plot.
    – carl
    Jul 1, 2023 at 13:02
  • I just tried opening the example PDF in Inkscape, and then I saved the SVG with no changes, and the file size is only 390kKB, which is much less than 1MB.
    – Billy Kerr
    Jul 1, 2023 at 16:27
  • @BillyKerr Indeed, this is only a minimum working example including 1000 dots. However, in my real-world examples i have tens of thousands of dots.
    – carl
    Jul 1, 2023 at 17:18

2 Answers 2

1

A union/combine operation here is not really going to work. Even if you select all the green circles, unite/combine them, and then do the same for the green and blue circles, it will mess up the arrangement and layering of all the objects.

There is nothing I know of that would automatically delete hidden objects. Perhaps an extension would be able to do it, but that would require coding.

There is a more practical method however which might help a bit. You can try saving the SVG using Inkscape's Optimised SVG option available in the File Type drop down when doing File > Save as

Set up Optimise SVG settings as follows:

enter image description hereclick to see larger

Using these settings I was able to get the SVG down to 167kb, which is still an increase but, less than three times as much.

enter image description here

8
  • Indeed, the MB I mentioned above was already referring to the optimized SVG file; Using this approach and prior grouping of all dots I get it even down to 133kb. I fear, that without excluding the hidden objects this won't get much lower.
    – carl
    Jul 1, 2023 at 17:32
  • @carl One possible solution might be to rasterize that part of the diagram. Does it have to be vector?
    – Billy Kerr
    Jul 1, 2023 at 17:47
  • not necessarily. I just want to have it ideally in a relatively good quality, rather than using, e.g., a screenshot or something like this.
    – carl
    Jul 1, 2023 at 17:57
  • @carl - then I would try that. You don't have to take a screenshot. Inkscape has the Edit > Make bitmap copy function. You will need to delete the vector objects afterwards - it's not automatic. They will be underneath the bitmap copy.
    – Billy Kerr
    Jul 1, 2023 at 18:21
  • @carl When I try this with your example, I get an SVG containing a bitmap, total file size is 52kb. It's fine as long as nobody zooms in.
    – Billy Kerr
    Jul 1, 2023 at 18:27
0

Inkscape 1.3 offers a new nice feature : objects >> flatten. You could try it. I don't know if it would withstand thousands of circles, yet.

https://wiki.inkscape.org/wiki/Release_notes/1.3#Flatten_Paths

2
  • Just to note that 1.3 is still in beta development
    – Billy Kerr
    Jul 3, 2023 at 6:29
  • 1
    Flattening does not guarantee that the file gets lighter, it can and often does make things significantly worse downstream.
    – joojaa
    Jul 3, 2023 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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