$ bzr diff
=== modified file 'phatch/core/lib/_pyexiv2.py'
--- phatch/core/lib/_pyexiv2.py 2009-06-09 14:46:38 +0000
+++ phatch/core/lib/_pyexiv2.py 2009-06-09 16:08:42 +0000
@@ -141,9 +141,14 @@
if not metadata:
return ''
#better try to figure out format by extension if it unknown
- ext = os.path.splitext(path)[-1]
- if ext:
- format = ext.upper()
+ if not format:
+ ext = os.path.splitext(path)[-1]
+ if ext:
+ format = ext[1:].upper()
+ if format in ['JPG','JPE']:
+ format = 'JPEG'
+ elif format == 'TIF':
+ format = 'TIFF'
if (format and not(format in WRITE_EXIF+WRITE_IPTC)):
raise Exception('pyexiv2: writing metadata to %s is not supported'%format)
image = pyexiv2.Image(path)
=== modified file 'phatch/core/pil.py'
--- phatch/core/pil.py 2009-06-09 14:46:38 +0000
+++ phatch/core/pil.py 2009-06-09 16:09:15 +0000
@@ -293,10 +293,14 @@
if format: info['Pil.Format'] = format
if metadata:
+ extract_info_metadata(info,location,image)
+ return info
+
+def extract_info_metadata(info,location,image=None):
+ if image: extract_info_pexif(info,image)
- extract_info_pyexiv2(info,location)
- extract_info_EXIF(info,location)
- return info
+ extract_info_pyexiv2(info,location)
+ extract_info_EXIF(info,location)
def get_exif_transposition(image):
orientation = get_exif_orientation(image)
@@ -434,10 +438,17 @@
#throw an error if pyexiv2 is not installed
if not exif:
raise ImportError(NEEDS_PYEXIV2)
- self.log += exif.flush(self.info['path'],self.metadata,
+ location = self.info['path']
+ self.log += exif.flush(location,self.metadata, self.info['Pil.Format'])
#as metadata has changed, use new source self.metadata = {}
+ #update
+ try:
+ image = Image.open(location)
+ except:
+ image = None
+ extract_info_metadata(self.info,location,image)
$ bzr diff core/lib/ _pyexiv2. py' core/lib/ _pyexiv2. py 2009-06-09 14:46:38 +0000 core/lib/ _pyexiv2. py 2009-06-09 16:08:42 +0000 splitext( path)[- 1] splitext( path)[- 1] WRITE_IPTC) ):
=== modified file 'phatch/
--- phatch/
+++ phatch/
@@ -141,9 +141,14 @@
if not metadata:
return ''
#better try to figure out format by extension if it unknown
- ext = os.path.
- if ext:
- format = ext.upper()
+ if not format:
+ ext = os.path.
+ if ext:
+ format = ext[1:].upper()
+ if format in ['JPG','JPE']:
+ format = 'JPEG'
+ elif format == 'TIF':
+ format = 'TIFF'
if (format and not(format in WRITE_EXIF+
raise Exception('pyexiv2: writing metadata to %s is not supported'%format)
image = pyexiv2.Image(path)
=== modified file 'phatch/ core/pil. py'
info[ 'Pil.Format' ] = format info_metadata( info,location, image) info_metadata( info,location, image=None) :
extract_ info_pexif( info,image) info_pyexiv2( info,location) info_EXIF( info,location) info_pyexiv2( info,location) info_EXIF( info,location)
--- phatch/core/pil.py 2009-06-09 14:46:38 +0000
+++ phatch/core/pil.py 2009-06-09 16:09:15 +0000
@@ -293,10 +293,14 @@
if format:
if metadata:
+ extract_
+ return info
+
+def extract_
+ if image:
- extract_
- extract_
- return info
+ extract_
+ extract_
def get_exif_ transposition( image): orientation( image) NEEDS_PYEXIV2) self.info[ 'path'] ,self.metadata, location, self.metadata,
self. info['Pil. Format' ])
self. metadata = {} location) info_metadata( self.info, location, image)
orientation = get_exif_
@@ -434,10 +438,17 @@
#throw an error if pyexiv2 is not installed
if not exif:
raise ImportError(
- self.log += exif.flush(
+ location = self.info['path']
+ self.log += exif.flush(
#as metadata has changed, use new source
+ #update
+ try:
+ image = Image.open(
+ except:
+ image = None
+ extract_
def get_filename( self,folder, filename, typ):
self. info[_t( 'new')+ DOT+_t( 'width' )], \
$ bzr commit -m "fix update metadata" sync/python/ phatch/ trunk/ core/lib/ _pyexiv2. py
Committing to: /home/stani/
modified phatch/core/pil.py
modified phatch/
Committed revision 713.