In ImageGear, both compression and conversion operations are closely related with Saving; these two operations are performed in ImageGear by setting some optional control parameters during saving operation.
On one hand, image compression can be accomplished by manipulating the specific parameters of the filter corresponding to the target format File Formats Reference. Such a filter can be accessed by passing the appropriate ImGearFormats value to the Get method of ImGearFileFilters object; see Loading and Saving for more information.
On the other hand, image conversion is associated with saving an image by specifying a relevant set of options through an instance of ImGearSaveOptions. ImageGear supports a variety of pixel formats (color spaces and channel depths). For more information, the user can refer to File Formats. However, most image file formats support only a limited set of pixel formats. For example, PNG format does not support CMYK color space, and JPEG Lossy format does not support storing 16-bit per channel pixel values. ImageGear provides conversion from a source image's pixel format into one of the pixel formats supported by the destination image file format.
Availability of a specific pixel format for saving depends on the requested compression, saving options, and filter control parameters.
ImageGear uses the following logic to select the pixel format for saving:
A special case is when the image color space has to be converted, and multiple choices of channel depths are available. In that case, ImageGear selects channel depths that are equal to the image's channel depths, rather than larger channel depths. This results in a slightly worse quality degradation, but avoids an unexpected increase in image size. For example, PNG format does not support CMYK color space, but it supports storing 8- or 16-bits per channel. ImageGear saves a 32-bit CMYK to PNG as 24-bit RGB rather than 48-bit RGB. ImageGear does not support conversion from multichannel truecolor color spaces (RGB, CMYK, etc.) into an indexed color space during saving.
The following code demonstrates how to convert a PNG image to a compressed JPG format image. For this example, we set the Lossy compression parameters for a local JPG filter. Then, we use an instance of ImGearSaveOptions object to set the conversion options for the output image. It is worth noticing how we combine image compression and conversion: set the parameter Filters of ImGearSaveOptions with the local JPG filter designed for compression.
For an example of how to convert a PDF document to an image, see PDF > How to... > Convert...