I apologize if this has been asked and answered already, but my Google Fu is apparently not up to snuff today. I have a black and white SVG drawing generated by an external program. An example SVG drawing is 3+ MiB, but if I spend significant time going through the file node-by-node in Inkscape, I can reduce the size to about 20KiB with zero loss in artistic intent. That is, the 20 KiB version looks exactly the same as the 3+MiB version, both visually when I zoom in all the way in Inkscape, and they generate a bit-for-bit equivalent PNG at a large resolution (confirmed with a Python PIL script to examine the differences).
The problem? The external program created each object not as a series of well-defined bezier curves and lines, but as many, many, many tiny line segments, each consisting of exactly two points. If you're a physicist, you can imagine them as little dipoles. Each end exactly overlaps the beginning of the next line segment. Image one is the line as I intend it to look visually, while image two shows how each line is actually composed of tiny line segments.
As a first round at reducing this file's resource footprint, I'd like to automatically join the overlapping nodes, as I currently only know how to manually join every. single. node pair with the Node tool's (F2) "Join selected nodes" functionality.
After "cleaning" an entire object, here is an example difference of the XML behind a manually "point joined" object:
Code: Select all
OLD PATH d="m 316.422,183.30866 0.34375,-0.63671 m -0.5,1.22265 0.15625,-0.58594 m -0.10157,1.02734 -0.0546,-0.4414 m 0.35929,0.9336 -0.30469,-0.4922 m 0.76953,0.89063 -0.46484,-0.39843 m 1.08594,0.59374 -0.6211,-0.19531 m 1.33204,0.29688 -0.71094,-0.10157 m 1.44532,0.0469 -0.73438,0.0547 m 1.44531,-0.25001 -0.71093,0.19531 m 1.40625,-0.49219 -0.69532,0.29688 m 1.27734,-0.74219 -0.58202,0.44531 m 1.12109,-0.93359 -0.53907,0.48828 m 0.91016,-1.02734 -0.37109,0.53906 m 0.58203,-1.13281 -0.21094,0.59375 m 0.32422,-1.1836 -0.11328,0.58985 m 0.0937,-1.17579 0.0195,0.58594 m -0.16013,-1.17969 0.14063,0.59375 m -0.39063,-1.12891 0.25,0.53516 m -0.57421,-1.08203 0.32421,0.54687 m -0.75,-0.99218 0.42579,0.44531 m -0.88672,-0.8789 0.46093,0.43359 m -0.90624,-0.73047 0.44531,0.29688 m -0.89063,-0.54688 0.44532,0.25 m -0.90626,-0.44532 0.46094,0.19532 m -0.90625,-0.34376 0.44531,0.14844 m -0.86328,-0.14844 0.41797,0 m -0.84375,0.0469 0.42578,-0.0469 m -0.87109,0.2969 0.44531,-0.25 m -0.83594,0.44531 0.39063,-0.19531 m -0.78907,0.53515 0.39844,-0.33984 m -0.75,0.63672 0.35156,-0.29688 m -0.67578,0.78906 0.32422,-0.49218 m -0.57422,0.98437 0.25,-0.49219 m -0.40625,1.03907 0.15625,-0.54688 m -0.25781,1.03516 0.10156,-0.48828 m -0.10156,1.02734 0,-0.53906 m 0.0469,0.98437 -0.0469,-0.44531 m 0.14065,0.9336 -0.0937,-0.48829 m 0.21088,0.83203 -0.11718,-0.34374 m 0.26562,0.64062 -0.14844,-0.29688 m 0.18751,0 -0.0391,0.29688 m 0.0391,-0.64062 0,0.34374 m -0.0547,-0.73046 0.0547,0.38672 m -0.14844,-1.02735 0.0937,0.64063 m -0.23433,-1.42969 0.14063,0.78906 m -0.31641,-1.67578 0.17578,0.88672 m -0.42578,-1.91406 0.25,1.02734 m -0.55469,-2.16016 0.30469,1.13282 m -0.67578,-2.31641 0.37109,1.18359 m -0.73047,-2.41797 0.35938,1.23438 m -0.76953,-2.41016 0.41015,1.17578 m -0.8164,-2.30468 0.40625,1.1289 m -0.76953,-2.21484 0.36328,1.08594 m -0.69532,-2.01954 0.33204,0.9336 m -0.63672,-1.72266 0.30468,0.78906 m -0.57422,-1.42578 0.26954,0.63672 m -0.51954,-1.17578 0.25,0.53906 m -0.44531,-0.88281 0.19531,0.34375 m -0.37109,-0.64063 0.17578,0.29688 m -0.0547,-0.10157 -0.1211,-0.19531 m 0.23047,0.39062 -0.10937,-0.19531 m 0.26952,0.39063 -0.16015,-0.19532 m 0.28907,0.39844 -0.12892,-0.20312" />
NEW PATH d="m 313.21494,172.23838 c 1.21688,3.54602 2.54702,7.10773 2.92914,10.86362 -0.32885,0.43229 -0.402,-0.71426 -0.43994,-0.96641 -0.13763,-1.47029 0.6823,-2.97674 2.02236,-3.6153 1.00235,-0.55183 2.17397,0.004 2.99404,0.63564 1.25742,0.91612 2.11753,2.70217 1.37489,4.19596 -0.87621,1.79645 -3.30364,2.70747 -5.10919,1.79505 -0.77851,-0.45569 -0.8693,-1.53242 -0.37807,-2.23176 0.0483,-0.0837 0.10105,-0.16477 0.15747,-0.2432 m -3.88289,-11.36717 c 0.11068,0.3112 0.22136,0.6224 0.33204,0.9336 m -1.0078,-2.75005 c -0.15541,-0.20441 -0.54158,-0.82062 -0.21858,-0.26945 0.35512,0.66939 0.62208,1.38021 0.89434,2.0859"
I note the removal of almost all of the 'm' commands, which are likely just places that I missed when manually doing this object.
Please take for granted that:
- I can't change the output of this external program. Blame proprietary software, if you'd like.
- Reducing the file size is important, as is reducing the editing complexity for our group.
Does Inkscape have an automated or efficient method to automatically join all overlapping nodes from a drawing? If not the entire drawing, how about just an object or group of selected points?
Thanks,
Kevin