[Image-SIG] Subsampling in Thumbnail Mode for Jpeg files..?

Fredrik Lundh fredrik at pythonware.com
Tue Aug 22 14:01:13 CEST 2006

Andreas Schmidt wrote:

> Sorry, I have a couple of questions:
> 1.  When I create a thumbnail with PIL it is extremly fast! Is this speadup
> due to the subsampling (using only the DC component) alone ? Or are there
> some other tricks ?

Simplified decoding is the only real "trick" here.

> 2. In thumbnail-Mode - does PIL still read the full jpeg stream from disk
> and then only reads the Bytes of the DC component ? Or does PIL directly
> read less Bytes from the disk, i.e. only the Bytes of the DC component ?
> How does it "know" which Bytes belong to the DC component ?

JPEG data consists of a compressed stream of DCT coefficients; to put the
original image back together, a JPEG decoder needs to decompress the co-
efficients, feed them through an inverse DCT transform, and use the result to
put the output image back together.

if the thumbnails are small enough, PIL skips the DCT step, using only the
DC component (=the average color for that 8x8 block).

> 3. I guess 1/8 is the limit for subsampling since 8x8 blocks are used and
> PIL is taking only the DC component is that case ?


> 4. What tricks is PIL using to speed up Thumbnail creation ?

I think we've gone through that more than once by now ;-)


More information about the Image-SIG mailing list