Png2eps is a small shell script to create an EPS (Encapsulated Postscript) file from a PNG (Portable Network Graphics) bitmap. The intention is to create a graphics format which can be included into LaTeX documents. It was developed for simultaneous production of PDF documents (with pdflatex which can handle PNG) and PS documents (with latex which can handle EPS). If you need to include bitmap graphics, you store it in PNG format and then run png2eps to create an EPS version. A better solution for JPEG graphics is jpeg2ps.
If available, LZW compression is used to reduce the size of the EPS file. All pixels are arranged in one single strip which also reduces the size of the output file and because with a smaller strip size my HP LJ 6MP printer had some problems printing those files.
The original resolution of the PNG file is also preserved, so an inclusion with \includegraphics should deliver the same figure size (even without the width or height parameters.
What is required?
- pngcheck to read the resolution and the title (if specified) from the PNG file,
- The TIFF library and (optionally) the LZW Compression Kit,
- pngtopnm and pnmtotiff from the netpbm collection for conversion, and, of course,
- the png2eps shell script itself.
This PNG file (4 colours, resolution of 245 dpi, file size: 14207 bytes) run through png2eps: (with LZW compression)
png2eps m2.png > m2.eps
results in this EPS file (file size: 20423 bytes). The decompression ratio is 1.4 (quite good).
Png2eps requires netpbm 10.1 or higher. For older netpbm versions, edit the script and remove the -indexbits=… option. (garbage in unused colormap entries, No colormaps < 8 bits; slightly larger EPS files)