Chapter 6.  Getting images out of GIMP

Table of Contents

1. Files
1.1. Saving Images
1.2. Saving Files
2. Preparing your Images for the Web
2.1. Images with an Optimal Size/Quality Ratio
2.2. Reducing the File Size Even More
2.3. Saving Images with Transparency

1.  Files

The GIMP is capable of reading and writing a large variety of graphics file formats. With the exception of GIMP's native XCF file type, file handling is done by Plugins. Thus, it is relatively easy to extend GIMP to new file types when the need arises.

Not all file types are equally good for all purposes. This part of the documentation should help you understand the advantages and disadvantages of each type.

1.1.  Saving Images

When you are finished working with an image, you will want to save the results. (In fact, it is often a good idea to save at intermediate stages too: GIMP is a pretty robust program, but we have heard rumors, possibly apocryphal, that it may have been known on rare and mysterious occasions to crash.) Most of the file formats that GIMP can open, can also be used for saving. There is one file format that is special, though: XCF is GIMP's native format, and is useful because it stores everything about an image (well, almost everything; it does not store “undo” information). Thus, the XCF format is especially suitable for saving intermediate results, and for saving images to be re-opened later in GIMP. XCF files are not readable by most other programs that display images, so once you have finished, you will probably also want to save the image in a more widely used format, such as JPEG, PNG, TIFF, etc.

1.2.  Saving Files

There are several commands for saving images. A list, and information on how to use them, can be found in the section covering the File menu.

GIMP allows you to save the images you create in a wide variety of formats. It is important to realize that the only format capable of saving all of the information in an image, including layers, transparency, etc., is GIMP's native XCF format. Every other format preserves some image properties and loses others. When you save an image, GIMP tries to let you know about this, but basically it is up to you to understand the capabilities of the format you choose.

Figure 6.1.  Example of an Export dialog

Example of an Export dialog

As stated above, there is no file format, with the exception of GIMP's native XCF format, that is capable of storing all the data in a GIMP image. When you ask to save an image in a format that will not completely represent it, GIMP notifies you of this, tells you what kind of information will be lost, and asks you whether you would like to “export” the image in a form that the file type can handle. Exporting an image does not modify the image itself, so you do not lose anything by doing this. See Export file.

[Note] Note

When you close an image (possibly by quitting GIMP), you are warned if the image is "dirty"; that is, if it has been changed without subsequently being saved. Saving an image in any file format will cause the image to be considered "not dirty", even if the file format does not represent all of the information from the image.

1.2.1.  Saving as GIF

Figure 6.2.  The GIF Save dialog

The GIF Save dialog

GIF Options
Interlace

Interlace : when this option is checked, the image will be displayed progressively on the Web page. It was interesting when computers and modems were slow, as it allowed to stop loading an image of no interest.

GIF comment

GIF comment: beware of do not insert characters outsite the ASCII range, because of the GIF format supports 7-bits ASCII texts only, that GIMP can't provide. If you insert inadvertitely a non-ASCII char, the option will be automatically disabled.

Animated GIF Options
Loop forever

Loop forever : when this option is checked the animation will start playing again repeatedly until you stop it.

Delay between frames if unspecified

Delay between frames if unspecified : you can set the delay, in millisecondes, between frames if it has not been set before. In this case, you can modify every delay in the Layer Dialog.

Frame disposal when unspecified

Frame disposal when unspecified : If this has not been set before, you can set how frames will be superimposed. You can select among three options :

  • I don't care : you can use this option if all your layers are opaque. Layers will overwrite what is beneath.

  • Cumulative Layers (combine) : previous frames will not be deleted when a new one is displayed.

  • One frame per layer (replace) : previous frames will be deleted before displaying a new frame.

1.2.2.  Saving as JPEG

JPEG files usually have an extension .jpg, .JPG, or .jpeg. It is a very widely used format, because it compresses images very efficiently, while minimizing the loss of image quality. No other format comes close to achieving the same level of compression. It does not, however, support transparency or multiple layers. For this reason, saving images as JPEG often requires them to be exported from GIMP.

Figure 6.3.  The JPEG Save dialog

The JPEG Save dialog

The JPEG algorithm is quite complex, and involves a bewildering number of options, whose meaning is beyond the scope of this documentation. Unless you are a JPEG expert, the Quality parameter is probably the only one you will need to adjust.

[Caution] Caution

After you save an image as a JPEG file, the image is no longer considered “dirty” by GIMP, so unless you make further changes to it, you will not receive any warning if you close it. Because JPEG is lossy and does not support transparency or multiple layers, some of the information in the image might then be lost. If you want to save all of the information in an image, use GIMP's native XCF format.

Quality

When you save a file in JPEG format, a dialog is displayed that allows you to set the Quality level, which ranges from 0 to 100. Values above 95 are generally not useful, though. The default quality of 85 usually produces excellent results, but in many cases it is possible to set the quality substantially lower without noticably degrading the image. You can test the effect of different quality settings by checking Show Preview in image window in the JPEG dialog. Checking this option causes each change in quality (or any other JPEG parameter) to be shown in the image display. (This does not alter the image, though: it reverts back to its original state when the JPEG dialog is closed.)

Advanced settings

Some information about the advanced settings:

Optimize

If you enable this option, the optimization of entropy encoding parameters will be used.

Smoothing

By using this option, you can smooth the image when saving.

Progressive

With this option enabled the compression of the image will be inserted progressively in the file. This is done with the intent to give a progressive refinement of the image appearance during the slow connection web downloads, similar and with the same purpose of the corresponding option present in the GIF images too.

Force baseline JPEG

Force creation of a baseline JPEG (non-baseline JPEGs can't be read by all decoders)

Subsampling

Human eye is not sensitive in the same way all over color spectrum. Compression can use this to consider as identical slightly different colors. Three methods are available :

  • 2x2, 1x1, 1x1 : important compression; suits images with weak borders but tends to denature colors.

  • 1x1, 1x1, 1x1 : preserves borders and contrasting colors, but compression is less.

  • 1x1, 1x1, 1x1 (4:2:2) : between other both.

Save EXIF data

JPEG files from many digital cameras contain extra information, called EXIF data, which specifies camera settings and other information concerning the circumstances under which the image was created. GIMP's ability to handle EXIF data depends on whether the “libexif” library is available on your system; it is not automatically packaged with GIMP. If GIMP was built with libexif support, then EXIF data is preserved if you open a JPEG file, work with the resulting image, and then save it as JPEG. The EXIF data is not altered in any way when you do this (which means that some of its fields are no longer valid). If GIMP was not built with EXIF support, this does not prevent files with EXIF data from being opened, but it does mean that the EXIF data will not be present when the resulting image is later saved.

DCT Method

DCT is “discrete cosine transform”, and it is the first step in the JPEG algorithm going from the spatial to the frequency domain. The choices are “float”, “integer” (the default), and “fast integer”.

  • float : The float method is very slightly more accurate than the integer method, but is much slower unless your machine has very fast floating-point hardware. Also note that the results of the floating-point method may vary slightly across machines, while the integer methods should give the same results everywhere.

  • integer (the default): This method is faster than “float”, but not as accurate.

  • fast integer : The fast integer method is much less accurate than the other two.

Save Preview

This option lets you save a thumbnail with the image.

Image comments

In this text box, you can enter a comment which will be saved with the image.

1.2.3.  Saving as PNG

Figure 6.4.  The “Save as PNG” dialog

The Save as PNG dialog

Interlacing

Interlacing: When this option is checked, the image is progressively displayed on a Web page. So, slow computer users can stop downloading if they are not interested.

Save background color

Save background color: If your image has many transparency levels, the Internet browsers which recognize only two levels, will use the background color of your Toolbox instead. But Internet Explorer does not use these informations.

Save gamma

Save gamma: informations about your monitor will be saved, so that the image will be displayed in the same way on other computers, provided that the display program supports these informations, what is rarely the case.

Save layer offset

Save layer offset: No interest. Images with layers are flattenned before saving to PNG and layer offset is taken in account.

Save Resolution

Save Resolution: Save the image resolution, in dpi (dot per inch).

Save creation time

Save creation time: That will be the date of last saving.

Save comment

Save comment: you can read this comment in the Info-window.

Save color values from transparent pixels

With this option is checked, the color values are saved even if the pixels are completely transparent.

Compression level

Compression level: Since compression is not lossy, the only reason to use a compression level less than 9 would be a too long time to compress file on a slow computer. Nothing to fear from decompression: it is as quick whatever the compression level.

Save defaults

Save defaults: If you click on this button, your settings will be saved and can be used by other savings by clicking on the Load defaults.

[Note] Note

Since PNG format supports indexed images, you have better reduce the number of colors before saving if you want to have the lightest file for the Web. See Section 9.6, “ Indexed mode.

Computers work on 8 bits blocks named “Byte”. A byte allows 256 colors. Reducing the number of colors below 256 is not useful: a byte will be used anyway and the file size will not be less. More, this “PNG8” format, like GIF, uses only one bit for transparency; only two transparency levels are possible, transparent or opaque.

If you want PNG transparency to be fully displayed by Internet Explorer, you can use the AlphaImageLoader DirectX filter in the code of your Web page. See Microsoft Knowledge Base [MSKB-294714]. Please note, that this should not be necessary for InternetExplorer 7 and above.

1.2.4.  Saving as TIFF

Figure 6.5.  The TIFF Save dialog

The TIFF Save dialog

Compression

This option give you the opportunity to choose the compression method that is appropriate for your image:

  • None : fast method, but resulting in a big file.

  • LZW : The image will be compressed using the “Lempel-Ziv-Welch” algorithm, a lossless compression technique. This is an old method, still efficient and fast. More informations at [WKPD-LZW].

  • Pack Bits : PackBits is a fast, simple compression scheme for run-length encoding of data. Apple introduced the PackBits format with the release of MacPaint on the Macintosh computer. A PackBits data stream consists of packets of one byte of header followed by data. (Source: [WKPD-PACKBITS])

  • Deflate

  • JPEG

Save color values from transparent pixels

With this option the color values are saved even if the pixels are completely transparent.

Comment

In this text box, you can enter a comment which will be associated with the image.