3

I have an svg image generated by another program (for visualisation of molecules) that is super complex, and I'd like to try and automatically simplify it. For example, a simple sphere with a gradient is drawn with 576 triangles. Is there a program (I have Inkscape and Illustrator, but I can download another free program if needed) capable to automatically convert these objects in simpler ones (e.g. a sphere with a gradient)? Just so you understand what I'm talking about, here's an example image: https://cloud.iacchi.casa/s/criQNyKNHaRpWMx

The idea is to get a 200 KB image instead of a 7 MB one, considering that I have to add more similar images together in a single final image, which shouldn't weigh 50 MB or so!

  • Those are some very complex images. There are a couple ways to merge them together, but nothing easily or quickly. It would be helpful to know why you need them merged together so we can give you the best options for your problem. – Alith7 Oct 27 '20 at 18:24
  • the idea is to get a 200 KB image instead of a 7 MB one, considering that I have to add more similar images together in a single final image, which shouldn't weigh 50 MB or so! – iacchi Oct 27 '20 at 19:08
  • I did edit your question so that anyone else can understand what exactly it is you are looking to do. – Alith7 Oct 27 '20 at 19:48
2

I would first opt to reconstruct as @BillyKerr explains in his answer.


However.... if knowledge of editing apps is limited and there are a great many images to process, there may be a way to refine the image and remove some of the complexity.

  1. Open the SVG in Illustrator
  2. Select All
  3. Hit the Merge button on the Pathfinder Panel (Window > Pathfinder)

This will simplify the artwork to a degree. In fact, you can hit the merge button a couple times, at least for your posted file. There's rarely anything such as "too much merging". Once objects are merged as far as they can, they won't merge further - so you can't really degrade the artwork to any real degree after that first click of the Merge button.

With your file I hit the Merge button twice and that was as far as things would reduce.

It still appears much the same...

enter image description here

But the underlying construction has been simplified considerably:

enter image description here



This took your 5.9mb file with 37,205 paths down to only 694k and only 1,464 paths.
That's a removal of over 35,000 objects.

This was a straight, no attention to specifics, SVG save from Illustrator CS6. I'm sure with some attention to the SVG code file size could be reduced a tad bit more. But the reality is, with all the objects, reconstruction may be the only way to get the file size under 500k.

  • thank you, that worked like a charm! – iacchi Oct 29 '20 at 9:50
2

Might be easier to just recreate these totally from scratch to be honest. I just tried using the shape builder to try and merge some shapes and Illustrator just sits there doing nothing.

The whole thing is only made up of a few individual shapes with gradients.

Here's an example showing the pieces (on the right), and recreated artwork from these pieces (on the left).

enter image description here

  • 1
    Took foooooorrrrreeeeevvvvveeeeerrrr to just open the file and the moment I saw it, this is what I thought :) – Scott Oct 27 '20 at 19:09
  • @Scott - yeah, same for me. Illustrator doesn't like it, nor Inkscape. I tried rasterizing in Illy, and it crashed. This is too much trouble to fix. Much easier to recreate from scratch. – Billy Kerr Oct 27 '20 at 19:11
  • I thought about re-creating them manually, but, given my skills, that would take me forever (I have about 24 images to do, some with more elements than the one I posted). Your screenshot is really nice - did you re-do all those balls and sticks manually? – iacchi Oct 27 '20 at 19:12
  • @iacchi - these are all just rounded rectangles, and circles with gradients. Nothing complicated. Really basic stuff for most graphic designers. True, it might take a while to do this, but it will still be quicker than trying to fix the original graphics. – Billy Kerr Oct 27 '20 at 19:15
  • @BillyKerr I agree, it should be easy, but I'm a chemist, not a graphic designer :P I think I'll go with the alternative and just export a high DPI raster and then work with that. Thanks for all the suggestions, though! – iacchi Oct 27 '20 at 19:27
2

If you are simply looking for a file size reduction, that's actually fairly easy to do.

First of all, you want to save out of Illustrator as a .AI file, that usually carries the least baggage for working with. I did that with no changes at all and that is the original (and largest) file in my screenshot of sizes below.

Second, if you select everything and select "Merge" in the Pathfinder Palette, it will merge everything that is touching and the same color.

Pathfinder Palette

Before Merge:

Before Merge

After Merge

After Merge

Note how it has greatly simplified the number of segments (the light blue lines). Saved as a .AI file and that is the file labeled "Merged". So just doing that reduced the file size to almost 1/3 of the original.

Finally, the center of the circles after the merge have a weird starburst made of strokes in the centers. They are all the same stroke weight, so you can select one of the lines, go to Select -> Same -> Stroke Weight to select all of the weird strokes and delete them.

Then, you can select all and "Merge" again to merge the centers into one shape. That got me the smallest file size labeled "Merged 2".

File sizes

Hope that helps you!

  • Great minds.... :) – Scott Oct 27 '20 at 19:46
  • yup! :) we took slightly different approaches with a good mix of info. – Alith7 Oct 27 '20 at 19:50
  • @Alith7 thanks to you as well! This path merger worked great for what I wanted to do. – iacchi Oct 29 '20 at 9:50
0

No! Though in this case its relatively easy to replace the artwork generation with some thing smarter than just dumping your opengl feed.

  • I agree that the export is stupid, but it's common to many 3D molecule drawing programs. Unfortunately, in this case I cannot change the program with which I do the export. – iacchi Oct 27 '20 at 19:09
  • @iacchi you dont need to alter the software to alter the export. All you really need is the 3D coordinates of the individual molecules and bond locations then you can do what Billy Kerr says automatically. – joojaa Oct 28 '20 at 6:05
0

Somebody has created a puzzle by exporting a 3D model as 2D vector which contains thousands of separate relatively simple shapes like triangles. Inkscape and illustrator struggle with it, but open it with GIMP. You can set the generated bitmap image to be say 6000 px for good resolution (there's WIDE empty areas at the edges).

Reject GIMP's offer to include also all paths. With them the image would be as complex as the SVG.

Crop the empty edges off. Then export the image as JPG if you can allow white background or as PNG if you need transparent background. The generated PNG had so much redundant parts that the image size was only about 216 kilobytes. Here's a zoomed snippet to show how sharp it is:

enter image description here

This is the uncropped image imported to GIMP; as you see more than 50% of the width is transparent emptiness.

enter image description here

The job needs practically zero graphic software skills and it really worked fast with free software. The drawback is that PNG is bitmap. But that's nothing if you have enough resolution and you are not going to make edits.

NOTE: The file size is 216 kilobytes, but the actual memory need when loaded into programs is tens of megabytes. If you have several images like this open at the same time for making a compilation your program can become sluggish. Programs which are intended for making layouts like InDesign can use linked images. They stay responsive by showing only a low res version during the composing work.

If you do not prepare printings, but files for onscreen watching only the pixel dimensions of the images can be reduced 70%. That reduces the memory need 90%.

Not asked: The construction principle "planar faces" can be faded in GIMP to some degree without making the image blurry by applying tresholded blur. It fades only borders which have less contrast than the given treshold:

enter image description here

This increases the PNG file size easily +100% because the redundancy inside the image decreases.

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.