ImageGear for C and C++ on Windows v19.10 - Updated
IG_save_thumbnail_set
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Save Functions > IG_save_thumbnail_set

This function allows you to save a thumbnail (miniature) version of the image together with the full image, if the format that you are saving to supports thumbnails.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_save_thumbnail_set(
   AT_BOOL bSaveThumbnails,
   AT_DIMENSION nWidth,
   AT_DIMENSION nHeight
);

Arguments:

Name Type Description
bSaveThumbnails AT_BOOL Thumbnail Flag: TRUE = enable saving thumbnails; FALSE = disable saving thumbnails.
nWidth AT_DIMENSION Width of thumbnail rectangle.
nHeight AT_DIMENSION Height of thumbnail rectangle.

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.

Sample:

None

Example:

 
Copy Code
HIGEAR hIGear;            // Will hold handle ret'd by IG_load_file  */
AT_ERRCOUNT nErrcount;    // Count of errs on stack upon ret from func */

nErrcount = IG_load_file("picture.tif", &hIGear);
if (nErrcount == 0)
{ 
    // To the file to be saved, add a thumbnail version of processed image
    IG_save_thumbnail_set(TRUE, 32, 32);
    nErrcount = IG_save_file (hIGear, "picture_new.jpg", IG_SAVE_JPG);
    // Destroy the image
    IG_image_delete(hIGear);
}

Remarks:

This function currently affects the following format filters: JPEG, PSB, PSD and Targa.

For Targa format, thumbnail cannot exceed 64 x 64 pixels. There is no limitation on thumbnail dimensions in JPEG-JFIF, but the result thumbnail image size should not exceed approximately 65536 bytes. Targa and JPEG-JFIF thumbnails are always 8-bit images. If the image data has a bit depth of greater than 8, ImageGear will automatically reduce the number of bits when creating the thumbnail.

When you load an image using one of the IG_load_...() functions, you will not automatically load any thumbnail that accompanies the main image. To load the thumbnail you must subsequently call one of the IG_load_thumbnail_...() functions. Similarly, when calling any of the IG_save_...() functions, the thumbnail will not be saved unless you first make a call to IG_save_thumbnail_set() function.

An alternative way to enable thumbnail saving is using filter control parameters. See descriptions of corresponding format filters in ImageGear Supported File Formats Reference.

If you load a file that has a thumbnail, and save it without having thumbnail saving enabled via IG_save_thumbnail_set() or via control parameters, only the main image will be saved to the destination file; no thumbnail will be saved.