skip to navigation
skip to content

SVGCompress 0.11

Compress svg graphics

Latest Version: 0.60


SVGcompress is a pure python module for simplifying/compressing svg (Scalable Vector Graphics) files. Have you ever tried to output a plot in vector format (pdf, svg, eps, etc.) and been surprised that your file weighs 10 or 20MB? Needed to submit a vector figure for publication but run up against the file size limit? Before you try to get away with the old standby of embedding a raster image in your vector and hoping the journal doesn’t notice, try SVGCompress! SVGCompress can help pare down your file size by:
Removing tiny polygons - Reduce the number of polygons in your image by removing those below a small threshold size. The size threshold can be based on polygon area or circumference. Simplifying shapes - Reduce the complexity of your polygons using the Ramer–Douglas–Peucker algorithm. Merging adjacent or overlapping shapes - Merging can be accomplished by taking the union of overlapping polygons or through the construction of a minimum convex hull.


SVGcompress requires the following non-standard libraries:
Numpy svg.path xml Shapely rdp

Usage Notes

Usage of SVGCompress is through the class Compress, or through the convenience function compress_by_method. The function svg_compress.test() contains usage examples demonstrating all of the compression methods with compress_by_method. Producing your figures in svg format can be done through Matplotlib. This is especially convenient if you have a graphics editor such as Inkscape (free) which will allow you to do things such as modify the font and color of text or lines directly in the svg, without having to re-run your code. You can also use this to convert one of your svg files into an alternate vector format such as pdf or eps.


SVGCompress/test contains examples of each compression algorithm on two different files: One is a demonstration graphic (test_vector.svg) and the other is an actual vector plot (map_test.svg)


0.1 - Not extensively tested. Please email me to let me know of any issues.

File Type Py Version Uploaded on Size
SVGCompress-0.11-py2-none-any.whl (md5) Python Wheel 2.7 2014-07-22 8KB
SVGCompress-0.11.tar.gz (md5) Source 2014-07-22 8KB