svgo icon indicating copy to clipboard operation
svgo copied to clipboard

merge redundant objects

Open fuddl opened this issue 11 years ago • 1 comments

If you want to see a pretty awful svg try to export one from openstreetmap

I uploaded an example at jsfiddl

You will see lines like this:

<image id="image5" width="5" height="5" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAABmJLR0QA/wD/AP+gvaeTAAAAPklEQVQImWP8//9//+c1DAwMDAwMhbwhLP2f1xzYu//q29vawqoMzgxMDAwMV9/ehpNMDAwM2sKqcJIRTT8Aqx0ZstcgmXUAAAAASUVORK5CYII="/>
<image id="image8" width="5" height="5" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAABmJLR0QA/wD/AP+gvaeTAAAAPklEQVQImWP8//9//+c1DAwMDAwMhbwhLP2f1xzYu//q29vawqoMzgxMDAwMV9/ehpNMDAwM2sKqcJIRTT8Aqx0ZstcgmXUAAAAASUVORK5CYII="/>
<image id="image11" width="5" height="5" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAABmJLR0QA/wD/AP+gvaeTAAAAPklEQVQImWP8//9//+c1DAwMDAwMhbwhLP2f1xzYu//q29vawqoMzgxMDAwMV9/ehpNMDAwM2sKqcJIRTT8Aqx0ZstcgmXUAAAAASUVORK5CYII="/>

<!-- it goes on like this for 97 lines... -->

its just the exactly same object 97 times. These 97 objects could be compared and merged into one. Replaced by references and so on. I'm sure this alone would reduce the file size to around 99%

fuddl avatar Mar 28 '14 17:03 fuddl

Actually, you can't merge such objects. SVG allows to reuse the with the <use> tag. But still in many quantities it's the same repetition, just somewhat shorter.

GreLI avatar Nov 04 '14 20:11 GreLI