JPEG compressor algorithm

ginsonic used Ask the Experts™

How can I get JPEG compression for maximum quality in a minimum file size?

Alike Adobe Photoshop compression or Advanced JPEG Compressor ?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2004
whats about the jpeg-object and its compressionquality-property

from the online help


Use CompressionQuality to set the compression quality of the JPEG image when writing out a jpeg image. Higher compression results in a poorer picture quality, but a smaller file size. This property is not used for reading in files.

TJPEGQualityRange is the type of the CompressionQuality property. The higher the TJPEGQualityRange value (up to a maximum of 100), the better the image quality, but the larger the file size. The lower the TJPEGQualityRange value (to a minimum of 1), the smaller the resulting file size, but at the expense of picture quality.

meikl ;-)

Usually JPGs are compressed at 80%
You may change this using the suggestion above and the classical StretchDraw aftet Bitmap.Assign (see "how to make a thumbnail" somewhere)

For the REAL algorithm itself, It should be findable using google (Huffman? Alike LZW? )

You could compute a difference map (e.g. subtract each pixel of the original image from the newly packed an unpacked temporary JPEG). Then compute the average difference of all pixels alltogether and choose a value that you consider to be acceptable for "good quality" using this difference.
Now do this with a binary search approach so long until you get to the optimal value for that particular image.

This can be used as method to find the optimal % value for a particular image to be compressed to JPG.


Sorry for delay :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial