Polygone

‘I couldn’t eat another byte.’ Mr Creosote remarks upon the consumption of a Mathematica postscript file.

Polygone is a utility that can significantly reduce the size of certain postscript graphics files. Some applications that create such files shade regions using an enormous number of tiny polygons, when a few larger ones could be used instead. Polygone parses postscript code looking for this defect, and merges polygons that share one or more common edges, and are shaded using the same colour. It can also remove the fine mesh that is sometimes visible in shaded areas (it is possible to do this manually; see the documentation for details). Polygone replaces an older utility called mps_repair, which only worked with files generated by Mathematica 6/7. Polygone can also process files generated by IDL 8.0, Mathematica versions 8–10, and possibly other applications as well. Please email me if you encounter a postscript graphics file that has either of the defects described above, but was generated by software other than Mathematica or IDL. Graphics saved in pdf can also suffer from these defects, but most software that creates pdf files can also create postscript, and the files generated by polygone can be converted to pdf using epstopdf or a similar utility.

An example of an oversized postscript graphic can be downloaded by clicking here. The size of the file is 7.6MB (pdf version, 1.5MB). This was generated by Mathematica 9.0 on an 64 bit linux machine, with the command

Export[ "test.eps" , ContourPlot[ Sin[ x * y ] , {x,-4,4} , {y,-4,4} ] ]
There does not seem be be any way to reduce the file size from within Mathematica, without bitmapping the figure. A repaired version of test.eps, generated by polygone can be downloaded by clicking here. The size of this file is 1.3MB (pdf version, 476KB).

Downloads

Version 4

     

Version 3

News

* December 2015 *

Version 6 of the free Fortran compiler, gfortran, is sufficiently advanced to compile polygone.

* New version June 2014 *

Faster and more flexible: Polygone 4 is here! Works with Mathematica 9 eps files (which version 3 could not process). The documentation contains a list of improvements and bug fixes.

* Bug fixes April 2012 *

  • Polygone no longer fails if the postscript includes paths that consist of a single point (sometimes created by Mathematica). I am grateful to Jens Nöckel for finding this problem.
  • A bug which sometimes caused Polygone to omit the last line of a postscript code has been eliminated.

* New version December 2011 *

Polygone 3 is superior to version 2 in a number of ways. It uses a much faster algorithm to find potential mergers, and it should work with any reasonably structured postscript code. The documentation contains a list of improvements and bug fixes.

Back to top