views:

211

answers:

2

I am developing image uploader for Flash 10. Is there a way to read jpeg quality of the browsed images.

+1  A: 

Unfortunately, it can't be done directly:

The quality factor is not stored directly in the JPEG file, so you cannot read the quality factor from the file. (from: Microsoft support pages...)

In more detail:

The quantization table that was used to compress an image is stored in the JFIF header, but the JPEG Quality Factor that was used to generate the quantization table is not stored along with the image and hence the original JPEG Quality Factor is lost. (from: JPEG Compression Metrics as a Quality Aware Image Transcoding, by Surendar Chandra and Carla Schlatter Ellis)

The above quote is from a paper which discusses ways to estimate the level of compression (by examining the quantization tables used in the image), but it doesn't look easy to implement: there's an example here which is part of the Image Magick codebase, but it's written in C.

Image Magick has been ported to Haxe, which can be complied into Flash code, so conceivably you could get something working, but I'm afraid it's beyond my skills to explain how!


EDIT: just found a similar question on SuperUser, which also mentions Image Magick.


EDIT: you might also be interested in the answers to this question, which asked how to get the size of an image without loading the whole file (good for dealing with images bigger than Flash can handle).

Richard Inglis
A: 

Thanks, it appears I need to write my own class in AS3 similar to Image Magick to read quality.