Metadata should be updated after a save.

Bug #385059 reported by Stani
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Phatch
Fix Released
Medium
Stani

Bug Description

After each save action.

Stani (stani)
Changed in phatch:
assignee: nobody → stani (stani)
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Stani (stani) wrote :

$ 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
Stani (stani)
Changed in phatch:
milestone: none → 0.2.1
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.