Derrick Rohl, who is currently doing astronomy research in Chile, sent me an email about LaTeX, the program he uses to write scientific research papers. Toward the end, he mentioned a feature he had recently discovered:
I didn’t realize [LaTeX] could do plots. It may be a while before I need to use them at all, but I noticed the labels and numbers on axes could be highlighted, rather than being part of a jpeg.
An astute reader of my blog might be taken aback by that last bit – namely, that using a JPEG image would be a good way to include a graph in a document. Why? Because, just last week, I glazed over some of the pitfalls of JPEG compression. Instead, I said, he should use a vector-based file format, such as EPS, to save images of this sort.
What’s the EPS advantage?
The issue is how the image is stored in the file. Vector-based formats, like EPS, SVG, PDF, etc. basically store a set of mathematical equations describing the image, whereas rasterized formats, like JPEG, PNG, GIF, TIFF, etc. store a pixel-by-pixel representation. Because vector-based formats store mathematical representations of the shapes in the image, they can be infinitely resized without losing quality. An EPS version of a line graph could be a fraction of the size of a TIFF file representing the same graph, but the EPS will not become pixellated, even when zoomed in 1000X.
What about JPEG?
JPEG, specifically, is a lossy compression format. If you open an image in Photoshop and save it as a JPEG at maximum quality without changing it at all, you will have lost some detail in the image itself. That loss of detail is barely noticeable in a photograph, but computer-generated graphics make JPEG artifacts much more obvious because they’re simpler images to begin with. If you absolutely cannot use a vector-based format (for instance, some companies don’t publish vectorized copies of their logo in order to protect their brand), you should export to PNG, not JPEG.