← Back to team overview

phatch-dev team mailing list archive

[Bug 385059] Re: Metadata should be updated after a save.

 

$ 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)
         
     def get_filename(self,folder,filename,typ):
         self.info[_t('new')+DOT+_t('width')], \

$ bzr commit -m "fix update metadata"
Committing to: /home/stani/sync/python/phatch/trunk/                           
modified phatch/core/pil.py
modified phatch/core/lib/_pyexiv2.py
Committed revision 713.                      

** Changed in: phatch
       Status: Confirmed => Fix Committed

-- 
Metadata should be updated after a save.
https://bugs.launchpad.net/bugs/385059
You received this bug notification because you are a member of Phatch
Developers, which is subscribed to Phatch.

Status in Phatch = Photo & Batch!: Fix Committed

Bug description:
After each save action.



References