ImageGear for C and C++ on Linux v18.8 - Updated
IG_save_JPEG_quality_set
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Save Functions > IG_save_JPEG_quality_set

This function sets the quality level for saving JPEG compressed images.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_save_JPEG_quality_set(
   UINT nQuality
);

Arguments:

Name Type Description
nQuality UINT An integer value from 1 to 100, where 100 represents the "highest quality" or least amount of pixel data lost.

Return Value:

Returns 0 if successful. Otherwise, returns the number of ImageGear errors that occurred during this function call.

Supported Raster Image Formats:

This function does not process image pixels.

Example:

 
Copy Code
AT_ERRCOUNT nErrcount = IG_save_JPEG_quality_set(95);

Remarks:

The quality level is the amount of data loss that will occur during JPEG compression. The default algorithm for JPEG compression used by ImageGear is a lossy scheme. This means that some data will always be lost during compression. Use this function to set the level of loss, where 100 means the least amount possible of pixel data will be lost during compression, and 1 allows the most loss (resulting in the smallest possible file after compression). Please see JPEG format filter description for more details.

JPEG quality is only used when an image is being saved, not during the decompression process.

This function has the same effect as using IG_fltr_ctrl_set to set the "QUALITY" control parameter for IG_FORMAT_JPG format filter.

A setting of 100 does not give you "lossless" JPEG. If you wish to save as lossless, use IG_fltr_ctrl_set to set the "TYPE" control parameter for IG_FORMAT_JPG format filter to IG_JPG_LOSSLESS before saving.

Use IG_save_JPEG_quality_get to obtain the current setting.