view MoinMoin/filter/image_jpeg.py @ 1918:bb2e053067fb

fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 27 Mar 2007 21:07:33 +0200
parents ebcebba1afb3
children b06ef2a53efa
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - image/jpeg Filter

    @copyright: 2006 MoinMoin:ThomasWaldmann
    @license: GNU GPL, see COPYING for details.
"""
import EXIF

def execute(indexobj, filename):
    """ Extract some EXIF data """
    try:
        f = file(filename, 'rb')
        tags = EXIF.process_file(f)
        f.close()
        # get rid of some big stuff:
        try:
            del tags["JPEGThumbnail"]
        except:
            pass
        try:
            del tags["EXIF MakerNote"]
        except:
            pass
        data = str(tags).decode('utf-8')
    except (ValueError, TypeError): # EXIF throws ValueError on unknown tags
                                    #             TypeError on other occassions
        data = u''
    return data