Full Name | JPEG File Interchange Format |
Format ID | ImGearFormats.JPG |
File Extension(s) | *.jpg, *.jpeg |
Data Type | Raster Image |
Data Encoding | Binary |
Multi-Page Support | No |
Alpha Channel Support | Read/write |
Metadata Update Support | Page |
ImageGear Platforms Support | WIN32, WIN64, Unix, Unix64, .NET, .NET64, MAC, Java |
ImageGear .NET provides two versions of JPEG filters. One is 100% "managed", and the other relies on native codecs and is optimized for the best compression and decompression performance. "Managed" filter is created by default when initializing IG common formats. Use CreateJpegFormat method to switch to optimized filter. Each filter has its own set of control parameters listed below:
Filter Control Parameter |
Type |
Default Value |
Available Values |
Description |
---|---|---|---|---|
SaveCosited |
bool |
false |
true, false |
Indicates whether the image should be compressed with cosited subsampling on saving. Known Issue: This control parameter does not affect CMYK images. |
Chrominance |
int |
10 |
Possible value in range [0,255] |
A value of zero means no compression (maximum color quality); 255 means maximum image color compression (minimal image color quality). JPEG images are stored in a compressed format. Compression is "lossy", which means when saving JPEG files, there is always data loss. Data loss is the result of JPEG ability to achieve high compression ratios. Higher quality settings result in less compression, while lower quality settings result in higher compression. Quality versus compression is a tradeoff. The image compression ratio can be adjusted by setting the Luminance and Chrominance properties. The Luminance property adjusts the luminance or grayscale quality, and the Chrominance property adjusts the chrominance or color quality. Lower settings for these properties result in higher quality images with less compression. Higher settings for these properties result in lower quality images with more compression. For general use photographic type images, setting Luminance = 24 and Chrominance = 30 provides about a 12:1 image compression ratio with minimal data loss. Compression ratios and perceived image quality will vary depending on the image. Chrominance should always have a value equal or higher than Luminance. |
Luminance |
int |
10 |
Possible value in range [0,255] |
See description for Chrominance. |
SubSampling |
ImGearDecimationTypes Enumeration |
Decim_2x2_1x1_1x1 |
Decim_1x1_1x1_1x1, Decim_2x1_1x1_1x1, Decim_1x2_1x1_1x1, Decim_2x2_1x1_1x1 |
This parameter is used in conjunction with the Chrominance and Luminance properties to control the compression ratio and the compressed image quality. For higher quality and lower compression, set Luminance and Chrominance in the low teens, and set SubSampling to "Decim_1x1_1x1_1x1" compression. For higher compression and lower quality, set Luminance and Chrominance in the low 20's and set SubSampling to "Decim_2x2_1x1_1x1" compression. |
UseOptimizedHuffmanCodes |
bool |
true |
true, false |
Indicates whether to use optimized Huffman codes during encoding instead of using default Huffman codes. |
LoadCosited |
bool |
false |
true, false |
Indicates whether the image was compressed with cosited subsampling. There is no flag in JPEG files to indicate compression with cosited (2-1-1) subsampling. Therefore, this fact must be determined independently by the application performing the file load method. |
QuadComponentColorSpace |
ImGearQuadComponentColorSpace Enumeration |
Auto |
Auto, Rgba, Cmyk |
This parameter allows you to explicitly specify the color space of the quad component JPEG image on load. Value of 'Auto' always sets color space to Cmyk. |
JpegSaveType |
Lossy |
Lossy, Lossless, Progressive |
Type for output JPEG format. See the Loading and Saving JPEG-Compressed Images section for details. |
The following metadata nodes are not supported by this filter, so they will not be available upon image load:
Filter Control Parameter | Type | Default Value | Available Values | Description |
---|---|---|---|---|
AllowLossy12bpcSaving | bool | true | true, false | Controls the saving to Lossy JPEG format. If True, saving of 12 bits per channel Lossy JPEG is allowed. This is the maximum channel depth supported by Lossy JPEG format. If source image's depth is more than 8 bits per channel, it will be saved to a 12 bpc JPEG. For example, 48-bit RGB image will be saved to 36-bit JPEG. Note that many viewers do not support 12 bpc JPEG. If False, all images are saved to 8 bpc JPEG, regardless of their channel depth. |
AllowRGBASaving | bool | true | true, false | Set this parameter to true to enable RGBA JPEG saving. Note, that there is no official standard for RGBA JPEG. This format is recognized as CMYK rather than RGBA by most third-party software. |
Quality | int | 70 | Possible value in range [1,100] | Gets/Sets quality value for Lossy and Progressive JPEG compression. See the JPEG Quality section for details. |
DecimationType | ImGearDecimationTypes Enumeration | Decim_2x2_1x1_1x1 | ImGearDecimationTypes Enumeration | Get/Set decimation value. For all available values see ImGearDecimationTypes Enumeration. |
Predictor | int | 1 | Gets/Sets predictor for lossless JPEG. See the Lossless JPEG Predictor Settings section for details. | |
SaveType | int | 0 (Lossy compression) | 0 (Lossy compression), 1 (Lossless compression) |
Get/Set type for output JPEG format. See the Loading and Saving JPEG-Compressed Images section for details. |
AllowCMYKSaving | bool | true | true, false | Set to true (default) to allow saving JPEG CMYK images. Set to false to save CMYK images to JPEG as RGB. |
SaveEXIFMetadata | bool | false | true, false | If true, EXIF metadata is saved. |
SaveExistingEXIFMetadata | bool | true | true, false |
This parameter controls the saving of existing EXIF metadata. By default (SaveEXIFMetadata = False, SaveExistingEXIFMetadata = True), ImageGear saves EXIF metadata if it exists in the source page, and does not save EXIF metadata if it does not exist in the source page. |
QuadComponentColorSpace | ImGearQuadComponentColorSpace Enumeration | Auto | Auto, Rgba, Cmyk, Ycck | This parameter allows you to explicitly specify the color space of the quad component JPEG image on load. Set this parameter to “Auto” to let ImageGear detect the best suitable color space, or set it to any other enumeration value to explicitly specify the color space. Please see ImGearQuadComponentColorSpace Enumeration for more details. |
SaveExistingEXIFMetadata works in combination with SaveEXIFMetadata parameter, as shown in the table below:
SaveEXIFMetadata | SaveExistingEXIFMetadata | Source Page has EXIF Metadata | ImageGear Action |
---|---|---|---|
False | False | No | Does not save EXIF metadata |
False | False | Yes | Does not save EXIF metadata |
False | True | No | Does not save EXIF metadata |
False | True | Yes | Saves existing EXIF metadata |
True | False | No | Saves default EXIF metadata |
True | False | Yes | Ignores existing and saves default EXIF metadata |
True | True | No | Saves default EXIF metadata |
True | True | Yes | Saves existing EXIF metadata |
JPEG is normally associated with the JPEG compression scheme, but it is also implemented into the JFIF file format. This format was developed to store JPEG-encoded data, and to exchange it between applications or operating systems that are normally incompatible.
The header of the JFIF contains the version number, the image dots per inch (DPI), or dots per centimeter, and an optional thumbnail (miniature) RGB representation of the main image. Version 1.02 handles thumbnails differently by storing them separately, rather than in the identification marker of the header.
The raw JPEG data is surrounded by two markers, an "SOI" (start of image) marker, and an "EOI" (end of image) marker. See Lossy JPEG Compression for more about JPEG compression.
JFIF is considered a non-proprietary file format. Many proprietary file formats contain JPEG data, incorporating their own application-specific data structures. Another non-proprietary format that uses JPEG-encoded data is TIFF file format, version 6.0.
ImageGear supports the reading and writing of three types of JPEG compression: baseline JPEG (Lossy), Progressive JPEG, and Lossless JPEG. When you load a JPEG-compressed file, ImageGear detects the type of JPEG compression and decompresses the image automatically. However, if you want to save an image with a JPEG compression scheme other than baseline JPEG, you must use "SaveType" parameter (for "Managed" filter) or "JpegSaveType" parameter (for "Native" filter) to specify the type of JPEG compression.
The JPEG format can store thumbnails, which are small representations of the original image. These images are stored in uncompressed form and can significantly decrease your overall compression ratio. (Uncompressed thumbnails sometimes occupy more space than the original JPEG image when compressed). Use this option carefully.
The Lossless JPEG scheme is "predictive" in nature; it uses the values of surrounding pixels in addition to the value of the original pixel to calculate a predictor value, which it then subtracts from the value of the original pixel. The resulting pixel value will be reduced such that it can be compressed more than the original value. The higher the number of neighboring pixels used, the higher the compression will be.
Regardless of the predictor value setting, the quality of the image will remain the same. The difference is that if you choose to optimize for space by setting a high predictor value, you will have to give up some speed, as the decompression will take longer to perform.
ImageGear lets you set the predictor value using "Predictor" control parameter. The ImageGear default for this setting is 1. The allowed range is 1-7. Values outside of the allowed range of 1-7 will be mapped to a value of 5. The graphic below shows a predictor (x) and three reconstructed samples (a,b,c) immediately to the left, immediately above, and diagonally to the left of the current sample
Lossless JPEG does not apply DCT for an image as per the Lossy JPEG compression. Instead, it uses a DPCM difference coding, which can be carried out with any one of seven different prediction modes. Correspondingly, the "Predictor" control parameter can be set to a value between 1 and 7. In the table below, you will see what algorithm your setting of 1-7 will use, where Px is the predictor, and Ra, Rb, and Rc are the reconstructed samples:
Value | JPEG DIS Prediction |
1 | Px = Ra |
2 | Px = Rb |
3 | Px = Rc |
4 | Px = Ra + Rb - Rc |
5 | Px = Ra + ((Rb-Rc)/2) |
6 | Px = Rb + ((Ra-Rc)/2) |
7 | Px = (Ra + Rb)/2 |
The baseline JPEG specification calls for a quality setting. The lower the setting, the greater the number of original pixels lost, and therefore the smaller the resulting compressed file will be. ImageGear lets you set the quality of compression with values of type INT between 1-100, where 100 provides the highest retention of original pixel values. A setting of 100 does not mean that the image includes 100% of all original pixel values. With Lossy JPEG, there is no such thing as "no loss". Control parameter for setting Lossy JPEG quality is "Quality" (for "Managed" filter). Please see description of "Chrominance" and "Luminance" control parameters to apply JPEG quality settings for the "Native" filter.
Brown, C. Wayne, and Barry J. Shepherd. Graphics File Formats: Reference and Guide. Greenwich, CT.: Manning Publications, 1992.
Kay, David C. and John R. Levine. Graphics File Formats. Windcrest Books, 1992.
Murray, James D. and William vanRyper. Encyclopedia of Graphics File Formats. Sebastopol, CA: O'Reilly & Associates, Inc., 1994.