This section describes all the optional parameters you can set for JPEG compression, as well as the "helper" methods provided to assist in this task. Proper setting of some parameters requires detailed understanding of the JPEG standard; if you don't know what a parameter is for, it's best not to mess with it!
It's a good idea to call jpeg_set_defaults() first, even if you plan to set all the parameters; that way your code is more likely to work with future JPEG libraries that have additional parameters. For the same reason, we recommend you use a helper method where one is provided, in preference to twiddling jpeg_compress_struct properties directly.
The helper methods are:
Method | Description |
---|---|
jpeg_set_defaults() | Sets all JPEG parameters to reasonable defaults, using only the input image's color space (In_color_space) |
jpeg_set_colorspace(J_COLOR_SPACE) | Sets the JPEG file's colorspace as specified, and sets other colorspace-dependent parameters appropriately |
jpeg_default_colorspace() | Selects an appropriate JPEG colorspace based on In_color_space, and calls jpeg_set_colorspace(J_COLOR_SPACE) |
jpeg_set_quality(Int32, Boolean) | Constructs JPEG quantization tables appropriate for the indicated quality setting |
jpeg_set_linear_quality(Int32, Boolean) | Same as jpeg_set_quality(Int32, Boolean) except that the generated tables are the sample tables given in the JPEG spec section K.1, multiplied by the specified scale factor |
jpeg_quality_scaling(Int32) | Converts a value on the IJG-recommended quality scale to a linear scaling percentage |
jpeg_add_quant_table(Int32, Int32[], Int32, Boolean) | Allows an arbitrary quantization table to be created |
jpeg_simple_progression() | Generates a default scan script for writing a progressive-JPEG file |
Compression parameters (properties) include:
Property | Description |
---|---|
Dct_method | Selects the algorithm used for the DCT step |
Jpeg_color_space | The JPEG color space |
Num_components | The number of color components for JPEG color space |
Optimize_coding | The way of using Huffman coding tables |
Restart_interval, Restart_in_rows | To emit restart markers in the JPEG file, set one of these nonzero |
Smoothing_factor | Gets/sets smoothing level |
Write_JFIF_header | Emits JFIF APP0 marker |
JFIF_major_version, JFIF_minor_version | The version number to be written into the JFIF marker |
Density_unit, X_density, Y_density | The resolution information to be written into the JFIF marker |
Write_Adobe_marker | Emits Adobe APP14 marker |