Re: Speeding up thumbnail generation (like multi threaded). Thoughts please.



2009/8/31 Dr. Michael J. Chudobiak <mjc avtechpulse com>:
> On 08/30/2009 09:51 AM, jcupitt gmail com wrote:
>> able to supply pixels at a certain size. In particular, libjpeg can do
>> a very quick load-at-1/8th-size read where it just decompresses enough
>> to be able to get the DC component of each 8x8 block. If you use
>> libjpeg like this you can expect around a 100x speedup of the
>> decompress step.
>
> The gdk-pixbuf jpeg loader does this already.

That's good, but I wonder if this feature is being used? I tried this
tiny program:

------------
#!/usr/bin/python

import sys
from vipsCC import *

thumb = 0
for name in sys.argv[1:]:
        # load at 1/8th size
        im = VImage.VImage (name + ':8')
        scale = 200.0 / im.Xsize()
        # bilinear shrink to 200 px across
        im = im.affine (scale, 0, 0, scale, 0, 0, 0, 0,
                int (im.Xsize() * scale), int (im.Ysize() * scale))
        # write as uncompressed bitmap
        im.write ('thumb%d.v' % thumb)
        thumb += 1
----------

then in a directory with 1,000 1920x1200 180kb jpegs (after flushing the cache):

$ time ~/try/thumb.py *.jpg
real	1m0.495s
user	0m33.442s
sys	0m8.109s

This is on a tiny netbook with a 1.6 GHz Atom CPU, a desktop machine
should be a lot quicker, though it will vary a lot with the detaiuls
of the test I guess (Mark's gdk-pixbuf version took 2m 30s for 1,900
files).

John


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]