ImageGear for Java User Guide > ImageGear Imaging Formats Reference > ImageGear Supported Compressions Reference |
All imaging files compressions can be divided on three basic types:
ImageGear supports the following compressions:
ASCII Compression
Full Name | American Standard Code for Information Interchange (ASCII) |
Compression ID | ImGearCompressions.ASCII = 23 |
ImageGear JAR File | imagegear2.core.jar |
Bit Depth | Gray level: 1, 8, 16 bpp; RGB 24, 48 bpp |
File Formats | PBM, PGM, PNM, PPM |
IG Platforms Support | WIN32, WIN64, Linux32, Linux64, MAC32, MAC64 |
Acronym for the American Standard Code for Information Interchange. ASCII is a code for representing English characters as numbers, with each letter assigned a number from 0 to 127. For example, the ASCII code for uppercase M is 77. Most computers use ASCII codes to represent text, which makes it possible to transfer data from one computer to another.
Text files stored in ASCII format are sometimes called ASCII files. Text editors and word processors are usually capable of storing data in ASCII format, although ASCII format is not always the default storage format. Most data files, particularly if they contain numeric data, are not stored in ASCII format. Executable programs are never stored in ASCII format.
CCITT Group 3 Compression
Full Name | CCITT Group 3 |
Compression ID | ImGearCompressions.CCITT_G3 = 3 |
ImageGear JAR File | imagegear2.core.jar |
Bit Depth | 1 |
File Formats | BTR, IBM IOCA, IBM MO:DCA, IMT, LV, NCR, TIFF |
IG Platforms Support | WIN32, WIN64, Linux32, Linux64, MAC32, MAC64 |
This is a 1-D version of the CCITT Group 3 compression scheme. It uses a static table of values to assign codes to run lengths. Frequently occurring run lengths are given smaller codes. (The most frequent are usually black runs of 2 or 4 pixels).
CCITT Group 3 2D Compression
Full Name | CCITT Group 3 2D |
Compression ID | ImGearCompressions.CCITT_G32D = 5 |
ImageGear JAR File | imagegear2.core.jar |
Bit Depth | 1 |
File Formats | BTR, IBM IOCA, IBM MO:DCA, TIFF |
IG Platforms Support | WIN32, WIN64, Linux32, Linux64, MAC32, MAC64 |
This is a 2-D version of the CCITT Group 3 compression scheme. It includes an error recovery algorithm for error transmissions; an error in one line does not translate to garbage output for the rest of the file. All modern fax machines support this format.
CCITT Group 4 Compression
Full Name | CCITT Group 4 |
Compression ID | ImGearCompressions.CCITT_G4 = 4 |
ImageGear JAR File | imagegear2.core.jar |
Bit Depth | 1 |
File Formats | CAL, IMR, KFX, BTR, IBM IOCA, IBM MO:DCA, IMT, LV, NCR, TIFF |
IG Platforms Support | WIN32, WIN64, Linux32, Linux64, MAC32, MAC64 |
The G4 compression is two-dimensional by default. It is very similar to the G3 2D compression, but it can produce compressed images that are half the size of a G3-compressed file.
It is slower, however, and does not have the same error recovery built in that the G3 format has. The decrease in speed occurs because G4 was designed specifically for encoding disk data. For this reason, it may be advisable to use the G3-Fax compression scheme if final compression size is not crucial, but speed is.
Deflate Compression
Full Name | Deflate compression |
Compression ID | ImGearCompressions.DEFLATE = 14 |
ImageGear JAR File | imagegear2.core.jar |
Bit Depth | 1, 2, 4, 8, 16 bpc |
File Formats | TIFF, PNG |
IG Platforms Support | WIN32, WIN64, Linux32, Linux64, MAC32, MAC64 |
"Zip-in-TIFF" compression. Deflate compression, sometime known as "zip" compression, uses another variant of the LZW compression method and so gives similar results, but is not restricted by any licenses.
Huffman Compression
Full Name | Huffman encoding |
Compression ID | ImGearCompressions.HUFFMAN = 2 |
ImageGear JAR File | imagegear2.core.jar |
Bit Depth | Any |
File Formats | NCR, PCD, TIFF, NEF, PEF |
IG Platforms Support | WIN32, WIN64, Linux32, Linux64, MAC32, MAC64 |
Developed in 1952 by David Huffman, this is one of the older compression methods. The encoding and decoding processes are complex relative to todayas standards, but the compression ratio can be high if the image contains many repeat data values. It is best used for images with little or no pixel noise, e.g., cartoons or drawings with large areas of the same color and intensity (like a monotone sky). This compression scheme is often used by other compression algorithms for extra compression.
The Huffman method uses a conversion table to assign codes for each value, based on frequency of occurrence. The file is scanned for all of its values, with the values and their frequency of occurrence tallied. Using a binary tree, values are paired off by frequency of occurrence, beginning with the least frequent values. As the tree progresses upward, the least occurring values at the bottom of the tree continue to be incremented a bit at a time, with one bit added for each new branch added to the tree. In the end, the values that occur the most (at the top of the tree) have the shortest codes.
A potential problem with this compression method is decoding; the fileas variable-length codes can cause the dropping or adding of a bit to the end of a line, thereby throwing off subsequent lines of data.
IBM MMR Compression
Full Name | IBM Modified Modified Read |
Compression ID | ImGearCompressions.IBM_MMR = 15 |
ImageGear JAR File | imagegear2.core.jar |
Bit Depth | 1 |
File Formats | IBM IOCA, IBM MO:DCA |
IG Platforms Support | WIN32, WIN64, Linux32, Linux64, MAC32, MAC64 |
Compression for black and white documents, similar to CCITT Group 4.
JPEG Compression
Full Name | JPEG compression |
Compression ID | ImGearCompressions.JPEG = 6 |
ImageGear JAR File | imagegear2.core.jar |
Bit Depth | Gray level: 8, 16 bpp; RGB: 24, 36 bpp; CMYK: 32 bpp; RGB+Alpha: 32 bpp |
File Formats | JPEG, DICOM, TIFF |
IG Platforms Support | WIN32, WIN64, Linux32, Linux64, MAC32, MAC64 |
This file compression method obtains a high compression ratio when used with detailed photographic images (its intended use). It is not a good compression choice for images with a small number of colors and high contrast edges, or for color-mapped data. Part of JPEGs success in high compression is due to the fact that it is a "lossy" compression method, meaning that the compression results in the loss of some data that is determined to be unimportant or unnecessary. This does not necessarily result in a visible reduction of image quality.
JPEG is highly flexible - it allows you to make a "quality" setting that determines the amount of loss that occurs and effects the size of the resulting compressed file.
The JPEG algorithm takes into account that the human eye is more sensitive to changes in brightness than to number of colors. Rather than saving the color data from each pixel in an image, it saves information on the rate of change of color, or "frequency information." More loss is allowed in the color data than in the brightness data. Some of the compression of the color is achieved by converting the RGB values to YCbCr color scheme. ImageGear supports two other JPEG compression modes--Lossless JPEG and Progressive JPEG.
Lossless JPEG Compression
Full Name | Lossless JPEG compression |
Compression ID | ImGearCompressions.JPEG = 6 |
ImageGear JAR File | imagegear2.core.jar |
Bit Depth | Gray level: 8, 16 bpp; RGB: 24, 48 bpp |
File Formats | JPEG, DICOM, TIFF |
IG Platforms Support | WIN32, WIN64, Linux32, Linux64, MAC32, MAC64 |
Lossless JPEG is an extension to the normal JPEG standard. One of the main algorithmic differences between the two is that the lossless JPEG does not apply a Discrete Cosine Transform. Rather, it uses a Predictive scheme. For each pixel, the values of one or several neighboring pixels are added to the value of the original pixel and then subtracted from the value of the original pixel. This method yields smaller values that require fewer bits per pixel to store.
ImageGear allows you to set the number of neighboring pixels to use in calculating the "predictor value".
Progressive JPEG Compression
Full Name | Progressive JPEG compression |
Compression ID | ImGearCompressions.JPEG = 6 |
ImageGear JAR File | imagegear2.core.jar |
Bit Depth | Gray level: 8, 16 bpp; RGB: 24, 36 bpp; CMYK: 32 bpp; RGB+Alpha: 32 bpp |
File Formats | JPEG |
IG Platforms Support | WIN32, WIN64, Linux32, Linux64, MAC32, MAC64 |
Progressive JPEG is considered an extension to the JPEG standard. It produces the same kind of lossy compression as normal JPEG compression (see above), except that it saves multiple copies of the same image using different levels of quality. There is no hard limit on the number of "scans" that may be stored.
When a Progressive JPEG-compressed image is decompressed, the filter decompresses the lowest quality image first. This can be helpful for quickly displaying a version of the image that you are loading. The benefit of this compression is the fast display of an image that is recognizable. The downside is that a JPEG decompression is performed more than once.
LZW (Lempel-Ziv-Welch) Compression
Full Name | Lempel-Zif-Welch (LZW) compression |
Compression ID | ImGearCompressions.LZW = 8 |
ImageGear JAR File | imagegear2.core.jar |
Bit Depth | 1, 4, 8, 16 bpc |
File Formats | GIF, TIFF |
IG Platforms Support | WIN32, WIN64, Linux32, Linux64, MAC32, MAC64 |
LZW compression works by finding patterns of data and assigning codes. It works best on highly-patterned images. Images with irregular patterning, or "noise," are not good candidates for this type of compression.
This compression scheme is "dictionary-based". This refers to the array of codes that identify each data pattern found in the image. The "dictionary" begins with a table that contains a code for each possible value in the image. If LZW compression is used on 8-bit images, a LZW "dictionary" is initialized with codes for 256 (28) values. As the file data is read, new values are added to the table for each unique pattern of data found. In the interest of saving space, the dictionary is not saved with the compressed file. The same dictionary is actually rebuilt when the data is decoded.
Packbits Compression
Full Name | Packed bits compression |
Compression ID | ImGearCompressions.PACKED_BITS = 1 |
ImageGear JAR File | imagegear2.core.jar |
Bit Depth | 1, 4, 8, 16 bpc |
File Formats | Adobe PSD, TIFF |
IG Platforms Support | WIN32, WIN64, Linux32, Linux64, MAC32, MAC64 |
Packbits compression seeks repeated data values. Packbits is considered an RLE (run-length encoding) compression scheme because it looks for "runs" or repeated values, and tallies their number, or "length". While its name implies that runs of bits are "packed" together, it is actually runs of bytes. It is very similar to the Macintosh Packbits compression used by Macpaint, except that the Packbits compression used for a TIFF allows the dimensions of the image to vary.
Packbits works by reducing repeated strings of the same characters into two components: the "run count" and the "run value". The count and value are stored in one byte each. Each two-byte grouping is referred to as an RLE packet. It is not a good compression scheme for images with large color ranges, as these do not tend to have many runs of the same color.
RAW Compression
Full Name | RAW compression (Uncompressed binary compression) |
Compression ID | ImGearCompressions.RAW = 2 |
ImageGear JAR File | imagegear2.core.jar |
Bit Depth | Gray level: 1, 8, 16 bpp; RGB 24, 48 bpp |
File Formats | PBM, PGM, PNM, PPM |
IG Platforms Support | WIN32, WIN64, Linux32, Linux64, MAC32, MAC64 |
Uncompressed binary compression. PBM, PGM, PNM, PPM formats use the term "RAW" for uncompressed binary compression, as opposed to ASCII compression.
RLE Compression
Full Name | Run length encoding compression |
Compression ID | ImGearCompressions.RLE = 7 |
ImageGear JAR File | imagegear2.core.jar |
Bit Depth | 1, 4, 8, 16 bpc |
File Formats | BMP, CLP, CUT, DCX, DICOM, GEM, IFF, MSP, PCX, RAS, SGI, TGA, WPG |
IG Platforms Support | WIN32, WIN64, Linux32, Linux64, MAC32, MAC64 |
RLE (Run Length Encoding) is normally a 1-dimensional compression scheme. Working sequentially from left to right and top to bottom, it compares the value of each byte with the value of the previous byte. Each data value is recorded into a "packet" of two bytes where the first byte contains the number of times the value is repeated, and the second packet contains the actual value. The bytes in the pocket are called the "run count" and the "run value". When an image contains many repeat values, the compression ratio is very high (for example, if every byte in a 100 byte image were the same, its size could be reduced to 2 bytes giving a 50:1 ratio). A very noisy image, or a plain ASCII text file typically does not compress well, and in fact could become larger for example, if all bytes in image are different from the ones next to them, the image doubles, because 2 bytes are used to store each byte in the image.