Memo‎ > ‎

Use .eps.gz in LaTeX

posted Jun 28, 2012, 6:40 PM by Teng-Yok Lee   [ updated Aug 17, 2013, 5:00 PM ]
To Embed figures in LaTeX files, .eps format is often used but the file sizes are too big. Using other formats such .PNG might be incompatible with TeX/LaTeX. Therefore, .EPS is still the better choice. To reduce the file size, .eps.gz is another good choice. The following steps could be applied.
  1. Prerequisite: Install gzip, grep, and ImageMagick. For Windows, please add the path to their executable to the environment variable PATH.
  2. Add the following rule at the beginning of the LaTeX file after the library graphix:
    • \DeclareGraphicsExtensions{.eps,.eps.gz}
    • \DeclareGraphicsRule{.eps.gz}{eps}{.bb}{}
  3. Convert the image, for instance, img.png to .eps
    • convert img.png img.eps
  4. Extract the BoundingBox
    • grep "%%BoundingBox" img.eps > img.bb
  5. Compress the .eps file
    • gzip -9 img.eps
The attached archive contain a Windows .bat file to convert an image file to .eps.gz with .bb. The most updated one now can be cloned from GIT: https://github.com/recheliu/png2epsgz/blob/master/png2epsgz.bat. Based on this script with the looping scheme in the shell, the images in a folder can be computed in a single command.


ċ
png2epsgz.zip
(1k)
Teng-Yok Lee,
Dec 9, 2012, 8:35 AM
Comments