Declaration
property JPEG_Quality: integer;
Description
The quality factor for the current JPEG image. Range is 1 to 100, though typical range is 60 (low quality) to 95 (high quality).
Higher values will improve image quality but require more disk space.
Note:
◼This property is not stored in a JPEG image, so it is never set when loading an image. Instead you set it when saving a JPEG to specify your desired compression
◼It is possible to estimate the original JPEG compression using
IECalcJpegStreamQuality or
IECalcJpegFileQuality
◼For TIFF files with
ioTIFF_JPEG compression, specify JPEG quality using
TIFF_JPEGQuality
◼For DICOM files with
iedcJPEG compression, specify JPEG quality using
DICOM_JPEGQuality
◼To set the quality for all relevant formats, set
ImageQuality
Default: 80 (Specified by
IOParamDefaults)
Quality Comparison
// Test Code
var
i, qual: Integer;
bmp: TIEBitmap;
begin
for i := 1 to 20 do
begin
qual := i * 5;
bmp := TIEBitmap.Create();
bmp.ParamsEnabled := True;
bmp.LoadFromFile( TestFilename );
bmp.Params.JPEG_Quality := qual;
bmp.SaveToFile( 'Test_'+IntToStr( qual )+'.jpg' );
bmp.Free;
bmp := TIEBitmap.Create();
bmp.LoadFromFile( 'Test_'+IntToStr( qual )+'.jpg' );
bmp.Resample( 2.0 );
bmp.Crop( MulDiv( bmp.Width, 1, 4 ), MulDiv( bmp.Height, 1, 4 ), MulDiv( bmp.Width, 3, 4 ), MulDiv( bmp.Height, 3, 4 ));
bmp.SaveToFile( '_'+IntToStr( qual )+'.png' );
bmp.Free;
end;
end;
TestImage1.png
| Quality Value | Size | Reduction | Sample | Zoomed to 200% |
| Original | 146 KB | - |
|
|
| 100 | 74 KB | 50% |
|
|
| 95 | 37 KB | 75% |
|
|
| 90 | 26 KB | 82% |
|
|
| 85 | 21 KB | 86% |
|
|
| 80 | 18 KB | 88% |
|
|
| 75 | 16 KB | 89% |
|
|
| 70 | 14 KB | 90% |
|
|
| 65 | 13 KB | 91% |
|
|
| 60 | 12 KB | 92% |
|
|
| 55 | 11 KB | 92% |
|
|
| 50 | 11 KB | 93% |
|
|
| 45 | 10 KB | 93% |
|
|
| 40 | 9 KB | 94% |
|
|
| 35 | 9 KB | 94% |
|
|
| 30 | 8 KB | 95% |
|
|
| 25 | 7 KB | 95% |
|
|
| 20 | 6 KB | 96% |
|
|
| 15 | 5 KB | 96% |
|
|
| 10 | 4 KB | 97% |
|
|
| 5 | 3 KB | 98% |
|
|
TestImage2.png
| Quality Value | Size | Reduction | Sample | Zoomed to 200% |
| Original | 113 KB | - |
|
|
| 100 | 55 KB | 52% |
|
|
| 95 | 25 KB | 78% |
|
|
| 90 | 18 KB | 84% |
|
|
| 85 | 14 KB | 88% |
|
|
| 80 | 12 KB | 89% |
|
|
| 75 | 11 KB | 91% |
|
|
| 70 | 10 KB | 91% |
|
|
| 65 | 9 KB | 92% |
|
|
| 60 | 8 KB | 93% |
|
|
| 55 | 8 KB | 93% |
|
|
| 50 | 7 KB | 93% |
|
|
| 45 | 7 KB | 94% |
|
|
| 40 | 7 KB | 94% |
|
|
| 35 | 6 KB | 95% |
|
|
| 30 | 6 KB | 95% |
|
|
| 25 | 5 KB | 95% |
|
|
| 20 | 5 KB | 96% |
|
|
| 15 | 4 KB | 96% |
|
|
| 10 | 4 KB | 97% |
|
|
| 5 | 3 KB | 97% |
|
|
Examples
// Load a JPEG and save it using the same compression quality
ImageEnView1.IO.LoadFromFile('C:\input.jpg');
ImageEnView1.IO.Params.JPEG_Quality := IECalcJpegFileQuality('C:\input.jpg');
ImageEnView1.IO.SaveToFile('D:\output.jpg');
// Convert a BMP to a JPEG at 90% quality
bmp := TIEBitmap.Create();
bmp.ParamsEnabled := True;
bmp.LoadFromFile( 'D:\input.bmp' );
bmp.Params.JPEG_Quality := 90;
bmp.SaveToFile( 'D:\output.jpg' );
bmp.Free;
See Also
◼TIFF_JPEGQuality
◼DICOM_JPEGQuality