views:

556

answers:

2

I am writing application using c++, in windows.

I want to get a thumbnail from jpeg, without decoding the whole image. How Can I read thumbnail from jpeg exif header? Can any one offer me a some sample code?

Many thanks!

A: 

Don't bother. You can create tumbnails very fast from JPEGs. They are compressed using DCTs on 8x8 pixel blocks. So, get the DC component (i.e. 0,0) of each block and you have an 1/64th thumbnail without decoding. Further scaling should be fast since there are hardly any pixels left.

MSalters
Many thanks, I had implementd the solution you said. It is good and fast, however because huffman codeing, it can not be very fast, I had to do haffman decoding block by block, It only save DCT time for each block. If there is a thumbnail image, it will be much faster. That's why I propose the problem.
+2  A: 

Unsurprisingly the library is called libexif has win32 port, and there is sample code for reading thubnail from file

greg