Compression Quality Factors

The quality factor (Q factor) is a number that determines the degree of loss in the compression process when saving an image to a one of the following file formats that supports Q factor:

JPEG (FILE_JPEG, FILE_JPEG_411, and FILE_JPEG_422) Formats

For 8, 12 and 24-bit files: You can set a value from 2 to 255, where 2 is the highest quality and 255 is the most compression. You can also use a factor of 0 to produce lossless JPEG files.

For 16-bit files: Only lossless jpeg is supported, so the only acceptable factor is 0.

JPEG Formats Notes

4:1:1 and 4:2:2 formats use subsampling for the color components. In the case of 4:1:1, the color components for 4 pixels are 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 save the file, then the color shift will increase. Due to this characteristic of the JPEG algorithm, the only ways to avoid this are to use 4:4:4, which has no subsampling, or avoid repeatedly resaving the file.

There is no subsampling for grayscale (8, 12, or 16-bit) files. Therefore, only FILE_JPEG and FILE_TIF_JPEG are supported for grayscale files. FILE_JPEG_411, FILE_JPEG_422, FILE_TIF_JPEG_411 and FILE_TIF_JPEG_422 only support 24-bit bitmaps.

LEAD CMP (FILE_CMP and FILE_CMW) Formats

8-bit, 12-bit and 24-bit only.

The acceptable range for a user-defined compression quality factor is from 2 to 255, where 2 is the highest quality and 255 is the most compression. The following predefined options are also acceptable:

Q Factor Predefined options for LEAD only
PQ1 [-1] Perfect 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.
PQ2 [-2] Perfect quality 2 This will produce a smaller file size than PQ1 while maintaining similar quality.
QFS [-3] Quality 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.
QMS [-4] Quality 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.
QS [-5] Quality 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.
SQS [-6] Size 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.
SQT [-7] Size 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.
MCQ [-8] Maximum compression keeping quality This option provides maximum compression while maintaining as high as possible image quality.
MC [-9] Maximum compression This option gives maximum compression. It is equivalent to a Q factor of 255.

CMW (FILE_CMW) Format

The QFactor can be 0 (lossless compression) or between 2 and 255 (lossy compression). 2 = highest quality and 255 = highest compression.

PNG (FILE_PNG) Format

The QFactor can be a value between 0 and 10. 0 = (default compression), 1 (fastest compression) to 9 (highest compression ratio), 10 (no compression).

MNG (FILE_MNG_JNG_411 and FILE_MNG_JNG_422) Format

The QFactor can be a value between 2 and 255.

JP2 (FILE_JP2) and J2K (FILE_J2K) Formats

The QFactor can be a value between −1 and 255. −1 and 0 represent lossless compression, while all the values between 1 and 255 are compression ratios. For example, a factor of 10 is a compression ratio of 10. A factor of 1 gives the best lossy quality, while a factor of 255 gives the highest compression. If the compression control used by the toolkit when saving J2K files is J2K_COMPRESSION_QFACTOR, then the compression used is based on the Qfactor passed to the SaveXXX function. For more information about setting the options for saving J2K files, refer to the FILEJ2KOPTIONS structure, L_GetJ2KOptions, or L_SetJ2KOptions.

JPEGLS (FILE_JLS, FILE_JLS_LINE, and FILE_JLS_SAMPLE) Formats

The QFactor can be a value between 2 and 255 (lossy compression), or 0 (lossless compression).

JPEG-XR (FILE_JXR, FILE_JXR_GRAY, and FILE_JXR_CMYK) Formats

The QFactor can be a value between 2 and 255 (lossy compression), or 0 (lossless compression).

FlashPix (FILE_FPX_JPEG_QFACTOR and FILE_FPX_JPEG) Formats

The QFactor can be a value between 2 and 255, where 2 is the highest quality and 255 is the most compression.

EXIF (FILE_EXIF_JPEG, FILE_EXIF_JPEG_422, FILE_EXIF_JPEG_411) Formats

The QFactor can be a value between 2 and 255, where 2 is the highest quality and 255 is the most compression.

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.