Skip to main content

Compress svg graphics

Project description

SVGCompress

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.

Installation

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.

Examples

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)

Version

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SVGCompress-0.10.tar.gz (8.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

SVGCompress-0.10-py2.py3-none-any.whl (9.2 kB view details)

Uploaded Python 2Python 3

SVGCompress-0.10-py2-none-any.whl (9.1 kB view details)

Uploaded Python 2

File details

Details for the file SVGCompress-0.10.tar.gz.

File metadata

  • Download URL: SVGCompress-0.10.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for SVGCompress-0.10.tar.gz
Algorithm Hash digest
SHA256 429249f9cec0b17d562a9bbb4656fa45ce93731530142477cc4ff126da3c9c08
MD5 dd6b6f53f1218bdd0cc4022a291cab31
BLAKE2b-256 81fa72901ef0ddbac38fc0f533315c5de4162bf1a7b519264d2d2ba53e763a8f

See more details on using hashes here.

File details

Details for the file SVGCompress-0.10-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for SVGCompress-0.10-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 85230fdee5803f6b7562298412c153f43beb701475a564eeae5c24712291c8a0
MD5 f648b46a443425591b6dc7399aca83ec
BLAKE2b-256 8fc8e3127db01ef1d6248203ca205f529b35900a0b9252bbf71e5dcf2b6d2776

See more details on using hashes here.

File details

Details for the file SVGCompress-0.10-py2-none-any.whl.

File metadata

File hashes

Hashes for SVGCompress-0.10-py2-none-any.whl
Algorithm Hash digest
SHA256 5c28728d946ef3360632545872c875be7dabc1a467715492671096e8e9ac6327
MD5 ec23cc87cc68a5d7d06c1a46b8a5d2eb
BLAKE2b-256 c112532dcd2d3774fa5029298d6525772cb43b09ed47e5c5085313778e06a959

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page