How to read embedded thumbnails from jpeg images?

I am writing a thumbnail viewer in C ++.

First I use EXIF ​​information to extract the thumbnail of the image, but the thumbnail in EXIF ​​is bad, with black bars. So I want to get a jpeg thumbnail, how can I do this?

Another question: does jpeg make a thumbnail equivalent to the EXIF ​​icon?

+4
c ++ thumbnails jpeg exif
source share
4 answers

If the EXIF ​​thumbnail is bad, you can create your own from JPEG itself without the need for full JPEG decoding.

Look for the source code for EPEG . This is part of the Enlightenment project at SourceForge, and it was part of the old EFL a year ago. You can still dig it from some old SVN commits or from the original tarball that can float around.

Basically, what EPEG does is it collects the DCT coefficients from the image and performs the scaling operation on them. The DCT coefficient is usually used as the base coefficient for an 8 × 8 pixel block. You can think of it as a single pixel. As a result, you have a (computationally free) thumbnail exactly 1/8 of the size of the original image. Scan it, like any image data, to the desired size.

+6
source share

In most cases, when people talk about thumbnail JPEG files, they mean that the file is JPEG-EXIF, and the EXIF ​​data contains a thumbnail.

However, it is true that JFIF 1.02 supports thumbnail. The sketch can be saved in the JFIF APP0 brand or the official JFXX APP0 extension mark; the thumbnail can be uncompressed RGB, JPEG or a palette. See http://en.wikipedia.org/wiki/JPEG_File_Interchange_Format#JFIF_segment_format for details.

+2
source share

The fastest and recommended way is libraries.

For example, www.exiv2.org may provide you with a library for inline sketch and EXIF ​​information. There are many alternatives, but I think this is a good solution.

0
source share

www.exiv2.org is a bad decision in my eyes. In other projects, there are too many depots. For example, Expat and zlib. If you want to come up with an easy solution that you can support yourself, I would recommend writing your own EXIF ​​decoder.

-one
source share

All Articles