Although memory is cheap nowadays, there are still situations where you have to watch the size of your scientific illustrations very carefully. One important case in point is the arXiv preprint archive. This database operates under strictly enforced policies regarding the size of submissions, and they also give some advice on how to keep the size of figures small. Another document explaining a variety of options has been created by Daniel Käps.
TeX world, it is by now standard to produce
pdflatex. In this case, you'll want your figures in
JPEG format. Regarding arXiv, the good news is that
pdflatex is meanwhile fully supported. What this means is that you won't have to convert figures to
EPS any more, in order to make them compatible with
latex. Although I do cover
EPS creation below, it is now essentially an obsolete format. Check the arXiv help for how to enable
pdflatex on their system (all that's needed is an explicit
My strategy for creating figures almost always involves going through Adobe Illustrator - this is the reason why this page was originally created. In Illustrator, to get small figures for arXiv or for your own web site, the final step is to choose
Export for Web in Illustrator, and create a
png file. On this page, I'll assume we have a PDF or Postscript figure whose file size needs to be reduced. The platform on which I usually do this is Mac OS X, but much of the following (in particular the command-line tools) is done the same way under Linux.
Conversion of vector graphics like PDF to bitmap format can be achieved with the ImageMagick software. In addition to a graphical user interface, it also offers all of its functionality via the command line in the Terminal. To create bitmaps, use the
convert utility, e.g.,
convert -scale 50% file.pdf file.jpg. The scale option is probably the most useful step for reducing the size of most figures, but there is also a
compress option whose default setting can be changed if necessary. If the resolution isn't to your liking, adjust it using something like
JPEG is an efficient way to store images with large amounts of color information in compressed (though lossy) form. Now the problem arises: what good does a compressed JPEG file do if I want it to be included in a paper written in LaTeX. As you should know, LaTeX is the preferred typesetting program for scientific publishing. One can include both PDF and JPEG files directly in LaTeX, provided the document is then processed with
pdflatex. This is pretty much the standard way of using LaTeX nowadays. However, if for some reason you find yourself having to use
latex instead, then the standard way to include figures is encapsulated postscript (EPS), and one cannot directly use PDF or JPEG files. Therefore, one may need to take the step back from JPEG to EPS.
This apparently redundant step can still lead to much reduced file sizes, if done right. The idea is that the jpeg file is hopefully much smaller than the original vector graphics we started out with. Now if we convert back to the vector-oriented EPS format, one would like to preserve this small size. EPS as well as PDF can of course contain bitmaps in addition to vector data, and what we want is an EPS that just acts as a wrapper for the JPEG we have already created. This adds very little extra size to the file.
To do this, one has to use a program that preserves the jpeg compression while creating EPS, otherwise even the EPS-wrapped bitmap will be bloated to an unacceptable size. On a Mac, there is already a tool that can do just this, and I've been using it since the days of the Classic Mac: the GraphicConverter application. I recommend using this because it gives you superb control over all the details of your bitmap image (such as color depth, antialiasing, dithering etc.) before exporting as EPS.
If you want a tool that can be used on PCs, Mac OS X and any other UNIX-based system alike, simply download and install jpeg2ps (C source code for UNIX). The installation is a standard UNIX procedure:
MANDIR = /usr/local/share/man/man1
sudo make install
man jpeg2psto see how the program is used.
It occured to me that you need to have a compiler installed in order to build
jpeg2ps yourself. This is something you'll want anyway if you're planning to make sense of any of the other "good advice" I'm giving on these pages... For information about installing the compiler and more, have a look at my setup page. If you don't want to compile anything, just stick with GraphicConverter.
A relatively "new" tool is sam2p. To compile it from source, you need the XCode Tools mentioned above. The advantage of
sam2p is that it accepts a variety of different input file formats. It also achieves higher compression than