Add support for exif tags by EXIF.py

Registered by Stani

EXIF.py is a read-only library for exif tags. It's pure python, so it can always be present. It seems better than PIL built-in support. Maybe we can drop support for Pexif and Zexif.

It's available from http://sourceforge.net/projects/exif-py/

Blueprint information

Status:
Complete
Approver:
Stani
Priority:
Medium
Drafter:
Stani
Direction:
Approved
Assignee:
Stani
Definition:
Approved
Series goal:
Accepted for 0.2
Implementation:
Implemented
Milestone target:
milestone icon 0.2.1
Started by
Stani
Completed by
Stani

Related branches

Sprints

Whiteboard

$ bzr diff
=== modified file 'copyright'
--- copyright 2009-05-28 16:14:00 +0000
+++ copyright 2009-05-29 16:25:21 +0000
@@ -117,6 +117,38 @@
    NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
    THE USE OR PERFORMANCE OF THIS SOFTWARE.

+The file phatch/other/EXIF.py is copyrighted and licensed as:
+ Copyright (c) 2002-2007 Gene Cash All rights reserved
+ Copyright (c) 2007-2008 Ianaré Sévi All rights reserved
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ 3. Neither the name of the authors nor the names of its contributors
+ may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
 The file phatch/other/findsystem.py is a source file of TTFQuery-1.0.1 and is
 licensed under its license:

=== modified file 'phatch/core/pil.py'
--- phatch/core/pil.py 2009-05-29 13:40:01 +0000
+++ phatch/core/pil.py 2009-05-29 16:19:18 +0000
@@ -23,6 +23,8 @@
 from cStringIO import StringIO
 from urllib2 import urlopen

+import EXIF
+
 import Image
 try:
     from ExifTags import TAGS as EXIFTAGS
@@ -175,6 +177,25 @@
                 info.update(new)
             except:
                 pass
+
+def fix_EXIF(tag):
+ if not (tag.startswith('EXIF') or tag.startswith('MakerNote')):
+ print tag
+ tag = 'EXIF.'+tag
+ return tag.replace(' ',DOT)
+
+def extract_info_EXIF(info,location=''):
+ if not os.path.isfile(location):
+ return
+ f = open(location, 'rb')
+ try:
+ tags = EXIF.process_file(f)
+ except:
+ tags = {}
+ f.close()
+ for tag, value in tags.items():
+ if tag != 'EXIF UserComment':
+ info[fix_EXIF(tag)] = value

 def extract_info_location(info,location='',folder=None):
     if not location.strip():
@@ -211,7 +232,8 @@
     info['transparency'] = image.info.get('transparency',None)
     #load Pil info
     for key, value in image.info.items():
- info['Pil'+DOT+key] = value
+ if key!='exif':
+ info['Pil'+DOT+key.title()] = value
     #retrieve properties
     width, height = size = image.size
     #summarize all photo properties in info
@@ -236,6 +258,7 @@
     if metadata:
         extract_info_pexif(info,image)
         extract_info_pyexiv2(info,location)
+ extract_info_EXIF(info,location)
     return info

 def prefix_dict(d,prefix,exclude=[]):

=== modified file 'phatch/pyWx/lib/imageInspector.py'
--- phatch/pyWx/lib/imageInspector.py 2008-05-04 20:35:50 +0000
+++ phatch/pyWx/lib/imageInspector.py 2009-05-29 16:19:57 +0000
@@ -36,7 +36,7 @@
 TAGS = [SELECT, ALL,'Pil']
 if pyexiv2:
     TAGS.extend(['Exif','Iptc'])
-TAGS.extend(['Pexif','Zexif'])
+TAGS.extend(['EXIF','MakerNote','Pexif','Zexif'])
 WX_ENCODING = wx.GetDefaultPyEncoding()

 def shortcut(key):

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.