views:

1324

answers:

3

I am writing a thumbnail viewer in c++.

I first make use of EXIF information to retrive an image's thumbnail, but the thumbnail in the EXIF is bad, with black bands. So I want to get the jpeg's embedded thumbnail, how can I do this?

Another question: does jpeg's embeded thumbnail equal to EXIF thumbnial?

A: 

The fastest and recommended way are libraries.

For example www.exiv2.org can provide you with the library for embedded thumbnail and EXIF info extraction. There is a lot of alternatives, but I think this one is a good solution.

Andrejs Cainikovs
+3  A: 

If the EXIF thumbnail is bad, you can generate your own from the JPEG itself, without needing to completely decode the JPEG.

Look for the source code for EPEG. It's part of the Enlightenment project on SourceForge, and was part of the old EFL a year ago. You can still dig it up from some old SVN commits or from a source tarball that might be floating around.

Basically, what EPEG does, is it collects the DCT coefficients from the image, and performs a rescaling operation on them. The DCT coefficient is normally used as the base coefficient for an 8x8 block of pixels. You can treat it as one pixel. As a result, you have a (computationally free) thumbnail exactly 1/8th the size of the original image. Rescale it as you would any image data to the desired dimensions.

greyfade
Many thanks, Is there any EPEG windows lib? How can I compile it under windows ?
It was written for the Enlightenment project, so the source code is originally very *nix-centric, but it was still written in a very OS-agnostic style. It should compile fine on Windows, straight out of the SVN checkout. There's no precompiled Windows lib to my knowledge. I believe there are makefiles already included for Windows.
greyfade
There's a link to some snapshots in the comments in my related answer:http://stackoverflow.com/questions/1316170/having-an-image-file-buffer-in-memory-what-is-the-fastest-way-to-create-its-thum
greyfade
A: 

www.exiv2.org in my eyes is a bad solution. There are just too many deps to other projects. Expat and zlib for instance. If you want to come up with a lightweight solution that you can support on your own, I would recommend to write your own EXIF decoder.

EFI