[python-win32] thumbnails

Mark Hammond mhammond at skippinet.com.au
Tue Oct 25 03:18:43 CEST 2005


There are a couple of types unsupported by the property storage code.  I did
try adding support, but the VT_CF structure is very poorly documented by MS.
After following the best instructions I could find, I did appear to get data
in CF_METAFILEPICT format, but I was unable to make SetClipboardData work
with the data.

I could send you the mods I made (let me know what Python version) to get
this raw data, but you would need to understand the METAFILEPICT structure
to make heads or tails of it.  Let me know if this is something would like.
Sadly these mods just missed build 205.

Cheers,

Mark.


-----Original Message-----
From: python-win32-bounces at python.org
[mailto:python-win32-bounces at python.org]On Behalf Of Renata Marin
Sent: Monday, 24 October 2005 7:16 PM
To: Python-win32 at python.org
Subject: [python-win32] thumbnails


Hello,
I want to find out if a MSOffice document has or not a thumbnail (preview
save picture). If yes I would like to save this thumbnail in a .jpeg file,
if no, i want to save a temporary preview picture of this document and
obtain the thumbnail in a .jpeg file.

Unfortunately this doesn't work. When  I do:
def PrintStats(filename):
    if not pythoncom.StgIsStorageFile(filename):
        print "The file is not a storage file!"
        return
    # Open the file.
    flags = storagecon.STGM_READ | storagecon.STGM_SHARE_EXCLUSIVE
    stg = pythoncom.StgOpenStorage(filename, None, flags )

    # Now see if the storage object supports Property Information.
    try:
        pss = stg.QueryInterface(pythoncom.IID_IPropertySetStorage)
    except pythoncom.com_error:
        print "No summary information is available"
        return
    # Open the user defined properties.
    ps = pss.Open(FMTID_UserDefinedProperties)
    props = PIDSI_TITLE, PIDSI_SUBJECT, PIDSI_AUTHOR, PIDSI_CREATE_DTM,
PIDSI_THUMBNAIL
    data = ps.ReadMultiple( props )
    # Unpack the result into the items.
    title, subject, author, created, thumbnail = data
    print "Title:", title
    print "Subject:", subject
    print "Author:", author
    print "Created:", created.Format ()
    print "Thumbnail:", thumbnail
If the thumbnail doesn't exists, it returns None, if It exists, it returns
me :

data = ps.ReadMultiple( props )
TypeError: Unsupported property type

Please, somebody can help me?
thanks
Rena



More information about the Python-win32 mailing list