Back to index

moin  1.9.0~rc2
image_jpeg.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - image/jpeg Filter
00004 
00005     @copyright: 2006 MoinMoin:ThomasWaldmann
00006     @license: GNU GPL, see COPYING for details.
00007 """
00008 from MoinMoin.filter import EXIF
00009 
00010 def execute(indexobj, filename):
00011     """ Extract some EXIF data """
00012     try:
00013         f = file(filename, 'rb')
00014         tags = EXIF.process_file(f)
00015         f.close()
00016         # get rid of some big stuff:
00017         try:
00018             del tags["JPEGThumbnail"]
00019         except:
00020             pass
00021         try:
00022             del tags["EXIF MakerNote"]
00023         except:
00024             pass
00025         data = str(tags).decode('utf-8')
00026     except (ValueError, TypeError, KeyError): # EXIF throws ValueError on unknown tags
00027                                               # TypeError on other occassions
00028                                               # KeyError too
00029         data = u''
00030     return data
00031