view MoinMoin/filter/image_jpeg.py @ 470:957d482215ac

lupy: some filters, update mode imported from: moin--main--1.5--patch-474
author Thomas Waldmann <tw@waldmann-edv.de>
date Mon, 13 Mar 2006 19:31:36 +0000
parents
children b3c18ea7db7d
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - image/jpeg Filter

    @copyright: 2006 by ThomasWaldmann 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, err: # EXIF throws ValueError on unknown tags
        data = u''
    return data