Menu

File types

↑Home


Basics

Bitmap graphics

For bitmap graphics an image is divided into (normally) square sections. Each of these pixels can be described by a set of numeric values.

The number of numeric values for each pixel and the interpretation depends on the color space. Some example color spaces are:

  • Grayscale
    uses a gray value (from 0 for black to maximum for white).
  • RGB
    An additive color space, used i.e. for screens, The values specify the amount of red, green and blue light for each pixel.
  • RGBA
    contains an additional component — the alpha channel — expessing the pixels opacity/transparency.
    If you place an image with alpha channel on top of colored background or on top of other images, you can see the objects in deeper layers through transparent regions of the image.
  • CMYK
    A subtractive color space, used i.e. for printers. The values specify the amount of cyan, magenta, yellow and black ink for each pixel.
  • HSB
    describes pixels by hue (a color tone), saturation (mixing against gray) and brightness.

The color depth (sometimes referred to as "bits per component") is the number of bits for the gray/color and alpha values.
In grayscale color space using 1 bit per component we can only express 0 and 1 (black and white). The use of 4 bits per components allows 16 shades 0000 (decimal 0, black), 0001, ...., 1110 (decimal 14), 1111 (decimal 15, white).

Some bitmap graphics file formats (i.e. GIF) use a color palette (color table). This table contains the color values for i.e. 256 colors. Pixel data consists of one number per pixel, the index in the color table.

Vector graphics

A vector graphics consists of drawing instructions like "draw a 1mm wide line from starting point Ps(xs,ys) to end point Pe(xe,ye) as solid line in black color."

On screens and printers vector graphics are converted into bitmap graphics for the device. The information about original paths, line widths and other graphics attributes allows optimized rendering on different targets depending on the target device's resolution and the zoom factor.
Vector graphics are scalable.


File type rules


  • Use vector graphics whenever possible.

  • When using bitmap graphics, prefer lossless file types.

  • Use lossy file types only for dedicated purposes (i.e. JPEG for photograms).


Vector graphics file formats

WXD

WXD files (*.wxd) are vector graphics files produced by the wxdkdraw program.
A *.wxd file can reference (import) bitmap graphics files.

Fig

Fig files (*.fig) are vector graphics files produced by XFig, jFig, or WinFIG.
A *.fig file can reference (import) bitmap graphics files.

GnuPlot

Gnuplot is a program for mathematical plotting. Input files for Gnuplot are text files containing instructions to set up the plot.

If you want to use a *.gp file with the gxhconvert script, make sure the *.gp file does not contain

set terminal ...
set output "..."

lines.
Terminal type and output file name are passed to gnuplot using the -e option by gxhconvert, depending on the output file type and other options you provided to gxhconvert.

SVG

SVG (*.svg, *.svgz, *.svg.gz) is a vector graphics file format, developed by Adobe, Inc.
SVG files can reference bitmap image files.
For conversions we have to consider three flavors of SVG:

  • Plain SVG
    contains just those tags mentioned in the file format standard. Most SVG viewers and renderers handle plain SVG.
  • Inkscape SVG
    is the file format used by the Inkscape program (a vector drawing application). Tags from the inkscape:... and sodipodi:... XML namespaces are used which are probably not understood by SVG viewers and renderers.
  • Inkscape+LaTeX SVG
    When exporting from Inkscape, we can optionally create a *.pdf/*.pdf_tex or *.eps/*.eps_tex combination (a LaTeX image) where text labels are passed to LaTeX to enable formulas and mathematical typesetting, i.e. "\(c^2=a^2+b^2\)". If an SVG file contains LaTeX texts, we can not use it without LaTeX.

For conversion paths we have to distinguish between Inkscape+LaTeX SVG files and SVG without LaTeX.
To use Inkscape+LaTeX SVG files with gxhconvert, make sure the file names end on "-il.svg", "-il.svgz", or "-il.svg.gz".

LaTeX document

A LaTeX document (*.tex) is a complete *.tex file one can process using latex or pdflatex. It can contain one or multiple LaTeX images.
A LaTeX document for one image may have one or two supporting files.

LaTeX image

A LaTeX image (*.tex) is a file containing LaTeX/TeX instructions for an image. Typically it loads a supporting PDF or EPS file containing the non-text graphics elements and typesets text labels on top of it.

The

\input{image.tex}

instruction (optionally embedded into a figure environment) is used in the LaTeX document to include the image.
Typical examples are:

  • *.tex or *.pgf files containing PGF instructions,
  • *.tex/*.pdf and *.tex/*.eps combinations produced by fig2lat from \*.fig files,
  • *.pdftex_t/*.pdftex and *.epstex_t/*.epstex combinations produced by fig2dev from *.fig files,
  • *.pdf_tex/*.pdf and *.eps_tex/*.eps combinations produced by inkscape when exporting *.svg files.

PDF

PDF (*.pdf) is a graphics format developed by Adobe, Inc.
It can contain both vector and bitmap graphics elements.
The intended purpose is electronic document exchange.

EPS/PS

PS (*.ps, *.eps) is a graphics format developed by Adobe, Inc.
It can contain both vector and bitmap graphics elements.
You can send a PS file directly to a PostScript printer, it is a printer language.
EPS is a subset of PS, intended to include images into print jobs.


Bitmap graphics file formats

PNG

PNG (*.png) is a lossless bitmap image graphics format.

JPEG

JPEG (*.jpg, *.jpeg) is a lossy bitmap image graphics format using DCT-based compression. You should use it for photograms only.

A quality parameter in the range 0%...100% can be used to control the image quality. Normaly you will use values in the range 80%...95%. Values below 25% or above 98% are not recommended.
For Ghostscript the quality parameter is not in percent, the range 0.0 ... 1.0 is used instead.

The interpretation of the quality parameter depends on the software used to generate JPEG files. Interpretation differs significantly between a widely used commercial program and programs using libjpeg.

In an environment focused on libjpeg-based software you can retrieve an approximation for a JPEG images quality parameter by running the

identify -format '%Q' yourimage.jpg

command. The identify program is in the ImageMagick package.

TIFF

TIFF (*.tif, *.tiff) is a bitmap image graphics format allowing multiple frames (images) in one file. Different compression mechanisms (both lossless and lossy) are available.
The TIFF V6.0 baseline standard lists a number of TIFF tags but some software vendors use their own non-standard TIFF tags when writing TIFF files. When processing TIFF files you should not be suprised when reading "unsupported TIFF tag" messages.
If you have a choice I recommend to avoid the TIFF file format, use PNG or JPEG instead.

ICO

An icon file contains multiple bitmaps of different size and color depth. We have to prepare all these bitmap/pixmaps.
If you ask which sizes and colors are required in an icon for a Windows application, opinions differ:

  • The Windows SDK documentation mentions 16x16 pixels with 16 colors (4 bits per color), 32x32 pixels with 16 colors and 48x48 pixels with 256 colors (8 bits per color).
  • If you create an icon for an application in Visual Studio 2008, the resource editor suggests 16x16 pixels, 32x32 pixels and 48x48 pixels. 16, 256 and 16 millions of colors (24 bits per color) for each size. Images with 16 or 256 colors use a color palette, 16 million colors use RGB values.
  • Other texts in the internet also recommend to add images in size 24x24 pixels in all 3 color depths too.
  • 16x16 is used in the task bar and in the left upper corner of a window. 24x24 is used in the start menu. 32x32 is used on the desktop. 48x48 is used in the explorer.
  • For favicon.ico files some texts also recommend 64x64 and 128x128 pixels.

Our procedures to create an ICO file also include the creation of a 32x32 pixels XPM file for use as application icon on non-Windows systems.

Icon files can have an image mask (each pixel is either fully opaque or fully transparent). When converting vector graphics formats (Fig, Gnuplot, PDF, PS/EPS, SVG) or images containing an alpha channel (PNG, TIFF) to ICO the image is mixed against a white background. Optionally we can create an image mask from alpha channel transparency data or from information about unused regions.

XPM

XPM is a bitmap image file type saving the image data as C source code (array of C strings). The wxWidgets libraries use XPM images for toolbar button images (width: 16 pixels, height: 15 pixels) and for application icons on non-Windows systems (width and height: 32 pixels).

When producing an XPM file using ppmtoxpm we have to specify a "-name name" option. The name must be a valid identifier in the C programming language.
The gxhconvert script uses xpm_filename where filename is the input file name without suffix with some corrections applied (minus and dots are replaced by underscores).

XPM files can have an image mask (each pixel is either fully opaque or fully transparent). When converting vector graphics formats (Fig, Gnuplot, PDF, PS/EPS, SVG) or images containing an alpha channel (PNG, TIFF) to XPM the image is mixed against a white background. Optionally we can create an image mask from alpha channel transparency data or from information about unused regions.


↑Home