Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.03.27
Compression Quality Factors
BasicConcepts    

The quality factor used when saving an image file depends upon its file format.

You can specify a quality factor when saving an image file to LEAD, JFIF, LEAD2JFIF, LEAD2JFIF, JTIF, LEAD1JTIF, or LEAD2JTIF. The quality factor is a number that determines the degree of loss in the compression process. You can set a value from 2 to 255, where 2 is the highest quality and 255 is the most compression.

For JFIF and JTIF compression only, you can also use a factor of 0 to produce lossless JPEG files.

NOTE: JFIF 4:1:1 and 4:2:2 formats use subsampling for the color components. In the case of 411, the color components for 4 pixels is averaged during compression. This will cause a color shift, but the shift is tolerable for low compression ratios. If you have high compression and repeated savings, then the color shift will increase. Due to inherent limitations of the JPEG algorithm, the only ways to avoid this are: (a) avoid repeated load and resave, or (b) use 4:4:4 format, which has no subsampling.

To set the quality factor when saving an image with any of these formats, use the qualityFactor parameter of the RasterImageViewer.Save method.

For LEAD CMP compression (8-bit, 12-bit and 24-bit only), set the qualityFactor to one of the following enhanced options:

Quality FactorPredefined options for LEAD only
-1Perfect quality 1. This option compresses all colors of a 24-bit file and maintains the quality of the original image at a smaller file size. As the name suggests, there is no visual loss of color at this setting.
-2Perfect quality 2. This will produce a smaller file size than using -1 while maintaining similar quality.
-3Quality far more important than size. This option removes colors not noticed by the human eye. Most viewers cannot tell the difference between an image compressed at this level and the original image.
-4Quality more important than size. While more colors are removed, most of them are colors or shades that are close to one another. The compressed image will appear very much like the original image. It will take some study to see the difference.
-5Quality and size equally important. This option provides the highest compression while maintaining good image quality. Try this option first, then move up or down the list accordingly to obtain acceptable compression size and image quality.
-6Size more important that quality (sharp). This option is recommended for images that have sharp edges. For example, an image that has a text overlay or an image with many straight lines. While it creates a larger file than the next option, it retains better edges.
-7Size more important than quality (less tiling). This option produces less tiling in the image than the previous options. However, it may distort text or straight lines. It is a good option for image database applications.
-8Maximum compression keeping quality. This option provides maximum compression while maintaining as high as possible image quality.
-9Maximum compression. This option gives maximum compression. It is equivalent to a quality factor of 255.
2...255Custom quality factor.

For the PNG format, the quality factor can be a value between 0 and 9. 0 = (default compression), 1 (fastest compression) ... 9 (highest compression ratio).

For JP2 and J2K files, the quality factor can be a value between –1 and 255. –1, and 0 represent lossless compression, while all the values between 1 and 255 are considered as compression ratios. For example a quality factor of 10 is a compression ratio of 10. A quality factor of 1 gives the best lossy quality, while a quality factor of 255 gives the highest compression.

For the ABC compression (RasterImageFormat.Abc and RasterImageFormat.TifAbc), the quality factor can be one of the following values:

Quality FactorPredefined options for LEAD only
0Lossless compression. This option compresses a 1-bit file and maintains image data unchanged. Highest quality.
1Lossy compression. This option removes the image's noisy pixels and compresses it to a smaller file size than using 0.
2Lossy compression. This option removes the image's border, if it exists, and compresses it to a smaller file size than using 1.
3Lossy compression. This option cleans up the image, removes its border if it exists, and compresses it to a smaller file size than using 2.
4Lossy compression. This option cleans up the image, removes its border if it exists, and compresses it to a smaller file size than using 3. However, it may distort text or straight lines.
5Same as using 4 but without the border remove or image clean processes.
6Lossy compression. This option cleans up the image, removes its border if it exists, and compresses it to a smaller file size than using 5. However, it may distort text or straight lines. Maximum compression.
7Same as using 6 but without the border remove or image clean processes.
8Lossy compression. Provides faster encode and decode speed than using 4 or 6. Provides the maximum compression.
9Same as using 8 but without the border remove or image clean processes.
10Faster lossless compression than using 0. This option compresses a 1-bit file and maintains image data unchanged. Highest quality. Does not produce compression ratios as high as using 0.
11Lossy compression. This is the fastest ABC lossy compression option. Does not produce compression ratios as high as the other lossy options.

For more information about LEAD and JPEG formats, refer to Compression Using LEAD and JPEG Formats.