Intelligent and Interactive Systems

User Tools

Site Tools


misc:graphics

Proper Choice of Graphics Formats

Creating your graphics

Create all graphics using the right tool and the right format. For example:

  1. From SciPy, Octave, Matlab, etc., export plots in vector format.
  2. Create line graphics with Inkscape. For LaTeX documents, TikZ may sometimes be a good choice.
  3. Process photographs with the GIMP - unless you overlay line graphics, in which case use vector tools like Inkscape or LaTeX graphics.

Never throw away essential information.

  1. Never convert vector to raster data.
  2. Never use lossy compression on line graphics.

The proper choice of graphics formats during processing and publishing has a critical impact on the quality and usability of the result. The two principal issues are:

  1. Preservation of information (in particular, resolution independence and avoidance of compression artifacts)
  2. Minimization of file size

The most important distinction is between vector (resolution independent) and raster (pixel) data. From this follows Rule Number One: Never convert vector data to raster data.

Then, file formats require attention because of the technological restrictions imposed by the publishing medium.

Vector Data (possibly combined with raster data)

  1. Never convert them to raster format.
  2. For print publishing: For PDFLaTeX, convert your graphics to (vector-format) PDF.1)
  3. For Web publishing: Use SVG. For legacy browers that do not yet support SVG, for maximum portability you may want to offer an alternative raster image (inside an <object> tag, for example), see below.

Raster Data

  1. Keep your graphics files reasonably small. Provide the resolution required for high-quality publishing, but do not preserve more than can be reproduced in the published form.
  2. If your data are composed of smooth transitions (typically, this includes all photographs and almost nothing else): Use a lossy format enabling a high compression rate at almost no visible loss of quality (JPEG/JFIF).
  3. If your data contain discrete colors, drawings etc. (this includes most non-photographic data, or photographic data with line graphics overlaid): Use a lossless format. PNG is highly recommended as it is open, includes compression, and is widely supported2). For discrete-color drawings, it yields better compression ratios than JPEG, at perfect quality, while JPEG creates approximation artifacts that are particularly obnoxious in print. 3)
Format Vector Raster
lossless lossy
Portable Document Format PDF
Scalable Vector Graphics SVG
Portable Network Graphics PNG
JPEG File Interchange Format JPG, JPEG, JFIF

Conversion

There are open-source tools for essentially all conversions that arise in practice. To convert PDF to SVG I recommend Inkscape.

1)
OpenOffice.org can import PDF, SVG and other vector graphics formats. I’m sure some of its proprietary look-alikes can also be convinced to grok vector graphics.
2)
Except for alpha-channel transparency by Microsoft products, but perhaps this information is outdated.
3)
There is almost no reason to use GIF anymore, as PNG is much more versatile and often more efficient. Exceptions are alpha-channel transparency for use with Microsoft products (well supported by the open-source community however) and animated raster graphics (MNG is still not very widely supported).
misc/graphics.txt · Last modified: 2018/09/03 19:35 (external edit)