My Postscript figure files are bloated
You can usually reduce or eliminate Postscript bloat if you understand your Postscript. Computers cannot understand Postscript well enough to do it automatically, because Postscript, like TeX, is a full-fledged programming language. However, there are several case-by-case solutions:
two Unix utilities can often fix the problem: convert is a bitmap-based image conversion program which is part of the ImageMagick graphics package. It interconverts nearly 100 different image formats, including several kinds of Postscript. eps2eps, which is part of the ghostscript package, converts fancy Postscript to simple Postscript. The output is frequently much shorter than the input, even though it is functionally identical. However, it does not help much with bitmaps.
Here are three possible reasons that your Postscript might be bloated, together with suggested remedies.
The file has a large header with macros and/or fonts. This is typical for commercial illustration programs such as Adobe Illustrator. One treatment for a file like this is to convert it with eps2eps, which is part of the ghostscript package. For example:
eps2eps fig.old.eps fig.new.epsYou should check the size of the output (preferably after compressing both the old and new figures) to make sure that it really is smaller.Another solution is not to use Adobe Illustrator. The Unix illustration program xfig produces very lean Postscript output. A newer alternative is dia.
The file is a large bitmap. This is usually because the resolution is substantially higher than necessary, because it is a black-and-white diagram saved as a full-color photograph, or because it is encoded inefficiently (using as many as 12 bytes per pixel). If you include the figure in your TeX document without rescaling it, then you should try:
convert -density 300x300 fig.old.eps eps2:fig.new.epsWith these options, convert produces 300dpi output in Postscript Level 2 format. Occassionally 600dpi is necessary for fine detail or 150dpi is necessary to further save space; resolutions other than these three are rarely the best choice. If you rescale the figure when you include it in your TeX document, you should change the parameters in convert so that the scaled resolution matches one of these values, or at least so that it's in a reasonable range.
- The file is an extremely complicated figure with tens of thousands of vertices, each given with many digits of precision. Sometimes you can fix the problem by changing the settings of the program that generated the figure. For example, a 3D plotting program might have an option to omit points that are hidden from view. Alternatively, you can convert it to a bitmap.
- The file was converted to a bitmap from JPEG. JPEG is an imperfect (or lossy) image compression format based on Fourier transforms. It is ideal for continuous-color images, such as photographs, that would be very large as bitmaps. Postscript Level 2 supports JPEG, and the correct way to convert is with a specialized utility such as jpeg2ps.