Search Contact information
University of Cambridge Home Department of Engineering
University of Cambridge >  Engineering Department >  computing help

Converting GIF images to JPEG on the CUED Teaching System

The GIF image format

The GIF image format uses lossless image compression in order to decrease the file size in a way which preserves image information. The Lossless compression technique that GIF uses is unable to compress images better than about 5:1 (e.g. a 640x480 8 bit image compressed to 60Kb).

The JPEG image format

JPEG uses lossy compression techniques and allows control over the degree of `lossy-ness.' Lossy compression causes loss of image information. For JPEG, this usually means that the image becomes blurred. The degree of blurring is controlled by the quality factor which is normally in the range 50% to 95%. This is an arbitrary measure of how much frequency domain information is preserved and 75% is considered adequate for most images. Compression ratios of 30:1 to 50:1 are not unusual for JPEG although increasing compression corresponds to increasing image defects.

It is important to remember that JPEG compression works well with natural images and badly with cartoon images. This is because the absence of sharp edges in the former tends to hide the effect of moderate JPEG compression.

Examples

Here are examples of differing levels of compression on a natural image.

Original GIF image : size 47935 bytes (1.3:1)

JPEG image; Q factor 75% : size 11502 bytes (5.6:1)

JPEG image; Q factor 25% : size 5590 bytes (11.4:1)

Here are the effects of JPEG compressing a line drawing type image - notice how JPEG compression actually leads to an increase in file size in this case:

Part of original GIF image : size 3302 bytes (19.4:1)

JPEG image; Q factor 75% : size 12977 bytes (4.9:1)

Conversion from GIF to JPEG

There are two ways of converting existing GIFs to JPEGs on the Teaching System

Using PBM routines

From a Unix command line enter :

tw100/jbloggs: giftoppm your.gif | cjpeg -quality 75 > your.jpg

Using gimp

Load in your gif image into gimp and "save as", giving the new file the suffix jpg.
© Cambridge University Engineering Dept
Information provided by Tim Love (tpl)
Originally written by Gopal Chand.
Updated 17th December, 1997