No adds anymore
 
 
Free Softwaare
 
  Thumbnail Extracter

Thumbnail Extracter

Fellow did you also asked you once what that bloody Thumbs.db file, in all your pictures folder, looks for?My watercow?

I surfed through the world wide web and I found many interesting things about it. About IStorage, IStream and other IFancy stuff. Also IFound some code examples to read and extract the content of a Thumbs.db,,,but it wasnt written in Python...

Thanks to "Python" and his fellows "pythoncom" and "pywintypes" I started to type...after many "Try","Except" and "Error", "Finally" I got it...I was so happy that iEat a whole duriaan!...

...actually there were to many lines so I decide to open a Thumb.db file with my friend YaHEbwinPy and i saw something interessting. There are embedded JFIF's file into it,,,okay fellow lets get the thumbnails extracted out with REALLY some lines in Python...and forget all the iStuff...how about iDuriaan?

As you see with regula(r) (s)expression, almost is done...A JFIF (JPEG File Interchange Format) start with that chunk "0xffd8 0xffe0 0x0010 JFIF" and end with that "0xd900".

thumbnail_extracter.py
import re

def extract_thumbnails(filename):
    try:
        thum_db_hndl = open(filename, 'rb')
        thum_db_content = thum_db_hndl.read()
        thum_db_hndl.close()
    except IOError, e:
        print e
        return 0
   
    found_jfif_file_content_list = re.findall("\xff\xd8\xff\xe0\x00\x10JFIF.*?\xd9\x00", thum_db_content, re.S)
   
    for jfif_item_cnt in range(len(found_jfif_file_content_list)):
        print "Create thumb_nail_file:", jfif_item_cnt
        thumn_nail_hndl = open("jfif_thumb_nail_item_%s.jpg" %(jfif_item_cnt), "wb")
        thumn_nail_hndl.write(found_jfif_file_content_list[jfif_item_cnt])
        thumn_nail_hndl.close()
   
    return 1

extract_thumbnails("images/Thumbs.db")

This 2 images are in the "images/" folder. After a thumbnail view in explorer, the Thumbs.db will be automatically created.

  • images/duriaan.ch-logo.jpg
  • images/python.org-logo.gif
  • images/Thumbs.db

Execute the script and then u will see 2 new thumb nail files will appear in your folder.

c:\thumby>python thumbnail_extracter.py
Create thumb_nail_file: 0
Create thumb_nail_file: 1
c:\thumby>dir
.
.
.
 Directory of C:\thumby

08/23/2008  04:22 PM    <DIR>          .
08/23/2008  04:22 PM    <DIR>          ..
08/23/2008  04:19 PM    <DIR>          images
08/23/2008  04:34 PM             1,654 jfif_thumb_nail_item_0.jpg
08/23/2008  04:34 PM             1,510 jfif_thumb_nail_item_1.jpg
08/23/2008  03:44 PM               645 thumbnail_extracter.py
.
.
.

jfif_thumb_nail_item_0.jpg

jfif_thumb_nail_item_1.jpg

Thats it my fellow...lets drink wintermelon and go fishing:)

 vvv
Home | CopyPathToClipboard | iPhone | RSSFeeder | EasyFileEraser | ThumbnailExtracter | HTMLTable2Img | FolderTreeToClipboard | Contact us  

Copyright © 2005-2008 duriaan.ch All rights reserved.