[jbrout] New patch to eliminate crashes on removal of tags. Exiftool should die!
Matej Cepl
mcepl at fedoraproject.org
Tue Jan 4 12:47:52 UTC 2011
commit e5c6b2483c289acea5bac8395ad1f48f1df5c40f
Author: Matěj Cepl <mcepl at redhat.com>
Date: Tue Jan 4 13:47:01 2011 +0100
New patch to eliminate crashes on removal of tags. Exiftool should die!
jbrout-eliminate-metadata-exiftool.patch | 252 ++++++++++++++++++++++++++++++
jbrout.spec | 9 +-
2 files changed, 259 insertions(+), 2 deletions(-)
---
diff --git a/jbrout-eliminate-metadata-exiftool.patch b/jbrout-eliminate-metadata-exiftool.patch
new file mode 100644
index 0000000..1c48ea1
--- /dev/null
+++ b/jbrout-eliminate-metadata-exiftool.patch
@@ -0,0 +1,252 @@
+diff --git a/jbrout/jbrout.py b/jbrout/jbrout.py
+index 19bc785..e608fcc 100755
+--- a/jbrout/jbrout.py
++++ b/jbrout/jbrout.py
+@@ -74,7 +74,7 @@ from jbrout.listview import ThumbnailsView
+ from jbrout.externaltools import ExternalTools
+ from jbrout.winbookmarks import WinBookmark
+ from jbrout.winpref import WinPref
+-from jbrout.tools import XMPUpdater, rawFormats
++from jbrout.tools import rawFormats
+
+ import tempfile,shutil
+
+@@ -878,6 +878,8 @@ class Window(GladeApp):
+ else:
+ JBrout.conf["normalizeName"] = False
+
++ # FIXME not used anywhere currently, although synchronization of tags could be useful.
++ # most likely should be reimplemented in plugins/syncTags/__init__.py
+ if not JBrout.conf.has_key("synchronizeXmp"):
+ ret=InputQuestion(self.main_widget,
+ _('Do you want JBrout to synchronize IPTC and XMP keywords (Recommended) ?'),
+@@ -914,7 +916,6 @@ class Window(GladeApp):
+ JBrout.conf["plugins"] = ["%s.%s"%(i.id,p["method"]) for i,c,p in JBrout.plugins.request("AlbumProcess",all=True)+JBrout.plugins.request("PhotosProcess",all=True)]
+
+ Buffer.size = JBrout.conf["thumbsize"]
+- XMPUpdater.synchronizeXmp=JBrout.conf["synchronizeXmp"] # Do we synchronize automatically ?
+
+ JBrout.db.setNormalizeName( JBrout.conf["normalizeName"] )
+ JBrout.db.setNormalizeNameFormat( str(JBrout.conf["normalizeNameFormat"]) )
+@@ -1947,7 +1948,6 @@ class Window(GladeApp):
+ finally:
+ self.showProgress()
+ sel.refresh()
+- XMPUpdater(ln).UpdateXmp()
+
+ def on_selecteur_menu_add_to_basket(self,b,sel):
+ ln = sel.getSelected()
+@@ -2135,7 +2135,6 @@ class Window(GladeApp):
+ i.addTags(l)
+ finally:
+ self.showProgress()
+- XMPUpdater(ln).UpdateXmp()
+
+ sel.refresh()
+ #~ context, x, y, selection, info, time = args
+@@ -2154,7 +2153,6 @@ class Window(GladeApp):
+ i.setRating(r)
+ finally:
+ self.showProgress()
+- XMPUpdater(ln).UpdateXmpRating()
+
+ sel.refresh()
+
+diff --git a/jbrout/jbrout/pyexiv.py b/jbrout/jbrout/pyexiv.py
+index 5017b5f..6a3e05c 100644
+--- a/jbrout/jbrout/pyexiv.py
++++ b/jbrout/jbrout/pyexiv.py
+@@ -126,8 +126,12 @@ class Exiv2Metadata(object):
+ for i in l:
+ assert type(i)==unicode
+
+- self._md["Iptc.Application2.Keywords"] = [i.encode("utf_8") for i in l]
+- self._md["Xmp.dc.subject"]=l
++ if l:
++ self._md["Iptc.Application2.Keywords"] = [i.encode("utf_8") for i in l]
++ self._md["Xmp.dc.subject"]=l
++ else:
++ del self._md["Iptc.Application2.Keywords"]
++ del self._md["Xmp.dc.subject"]
+
+
+ def clearTags(self):
+@@ -242,9 +246,6 @@ class Exiv1Metadata(pyexiv2.Image):
+
+ def Image(f):
+ if hasattr(pyexiv2,"ImageMetadata"):
+- # pyexiv2 >= 0.2
+- print "***WARNING*** : YOU ARE USING pyexiv2>0.2 (jbrout doesn't support very well this new version ! not fully tested ! some things are not implemented !!!)"
+-
+ return Exiv2Metadata(pyexiv2.ImageMetadata(f))
+ else:
+ # pyexiv2 < 0.2
+diff --git a/jbrout/jbrout/tools.py b/jbrout/jbrout/tools.py
+index a999799..2b7d49b 100755
+--- a/jbrout/jbrout/tools.py
++++ b/jbrout/jbrout/tools.py
+@@ -158,9 +158,6 @@ class _Command:
+
+ return out #unicode
+
+-
+-class NotImplemented(Exception): pass
+-
+ class PhotoCmd(object):
+
+ file = property(lambda self: self.__file)
+@@ -680,88 +677,6 @@ isreal : %s""" % (
+ # else:
+ # return file
+
+-class XMPUpdater():
+- #synchronizeXmp = None
+-
+- def __init__(self,photo_list):
+- """XMPUpdater is in charge of manipulating XMP data.
+- It might disapear when pyexiv2 will have XMP support"""
+-
+- # List of pictures
+- self.list=photo_list
+-
+- # List of pictures' name
+- if len(self.list)>0:
+- if type(self.list[0]) in [str,unicode]:
+- self.pictures=self.list
+- else:
+- self.pictures=[]
+- for picture in self.list:
+- self.pictures.append(picture.file.encode('utf-8'))
+-
+- def SyncXmpIptc(self):
+- """Merge XMP and IPTC if option is on"""
+- if not self.synchronizeXmp:
+- return 1
+- self.DoMergeXmpIptc()
+-
+- def UpdateXmp(self):
+- """Save tags to XMP subjects if option is on"""
+- if not self.synchronizeXmp:
+- return 1
+- self.DoSaveXmp()
+-
+- def UpdateXmpRating(self):
+- """Save Rating to XMP if option is on"""
+- if not self.synchronizeXmp:
+- return 1
+- self.DoSaveXmpRating()
+-
+- def DoMergeXmpIptc(self):
+- """Import XMP subjects, merge with IPTC keywords and save to both"""
+- if not self.synchronizeXmp:
+- return 1
+- #initialize command
+- command=[_Command._exiftool]
+- #remove subject from keywords to avoid duplicates
+- command.extend(["-r", "-overwrite_original", "-addtagsfromfile@", "-keywords-<subject"])
+- #add pictures list
+- command.extend(self.pictures)
+- ret= _Command._run( command )
+-
+- #initialize command
+- command=[_Command._exiftool]
+- #add subject to keywords
+- command.extend(["-r", "-overwrite_original", "-addtagsfromfile@", "-keywords+<subject"])
+- #add pictures list
+- command.extend(self.pictures)
+- ret= _Command._run( command )
+-
+- #initialize command
+- command=[_Command._exiftool]
+- #copy keywords to subect
+- command.extend(["-r", "-overwrite_original", "-subject< keywords"])
+- command.extend(self.pictures)
+- ret= _Command._run(command)
+-
+- def DoSaveXmp(self):
+- """Save tags to XMP subjects"""
+- if not self.synchronizeXmp:
+- return 1
+- command=[_Command._exiftool]
+- command.extend(["-r", "-overwrite_original", "-subject< keywords"])
+- command.extend(self.pictures)
+- ret= _Command._run(command)
+-
+- def DoSaveXmpRating(self):
+- """Save rating to XMP"""
+- if not self.synchronizeXmp:
+- return 1
+- command=[_Command._exiftool]
+- command.extend(["-r", "-overwrite_original", "-XMP:Rating< EXIF:Rating", "-XMP:RatingPercent< EXIF:RatingPercent"])
+- command.extend(self.pictures)
+- ret= _Command._run(command)
+-
+ if __name__=="__main__":
+
+ #~ f=u"images_exemples/IMG_3320.JPG"
+diff --git a/jbrout/jbrout/winshow.py b/jbrout/jbrout/winshow.py
+index 0eec1a9..4588834 100755
+--- a/jbrout/jbrout/winshow.py
++++ b/jbrout/jbrout/winshow.py
+@@ -16,7 +16,6 @@ from __main__ import Buffer,GladeApp,JBrout
+ from commongtk import WinKeyTag
+ from common import cd2rd,format_file_size_for_display
+ from jbrout.externaltools import ExternalTools
+-from jbrout.tools import XMPUpdater
+ #TODO: add ops : add/del from basket
+ #TODO: add ops : external tools
+
+@@ -220,7 +219,6 @@ class WinShow(GladeApp):
+ # capture keypad 0-5 for rating
+ currentNode.setRating(int(b.string))
+ self.draw()
+- XMPUpdater([currentNode]).UpdateXmpRating()
+
+ return 0
+
+@@ -339,7 +337,6 @@ TAGS :
+ currentNode = self.viewer.display.node
+ currentNode.delTag(tag)
+ self.draw()
+- XMPUpdater([currentNode]).UpdateXmp()
+
+ def on_delete_clicked(self,*args):
+ if self.isModify:
+diff --git a/jbrout/plugins/syncTags/__init__.py b/jbrout/plugins/syncTags/__init__.py
+index a4ad9f7..9a789a5 100644
+--- a/jbrout/plugins/syncTags/__init__.py
++++ b/jbrout/plugins/syncTags/__init__.py
+@@ -13,7 +13,6 @@
+ ##
+
+ from __main__ import JPlugin
+-from jbrout.tools import XMPUpdater
+
+ class Plugin(JPlugin):
+ """Plugin to perform mass tagging changes"""
+@@ -27,11 +26,15 @@ class Plugin(JPlugin):
+ #def albumEntries(self,l):
+ # return [(300,_("Import Tags"),True,self.importAlbumTags)]
+
++ def __SyncXmpIptc(self):
++ # synchronize XMP and IPTC tags
++ raise NotImplementedError
++
+ @JPlugin.Entry.PhotosProcess( _("Import Tags"), order=8100 )
+ def importTags(self,imgList):
+ """Import tags used in the given image list (IPTC and XMP) and merge them together"""
+ self.showProgress( 0, 1 , _("Importing Tags") )
+- XMPUpdater(imgList).SyncXmpIptc()
++ self.__SyncXmpIptc()
+ self.showProgress()
+ return True
+
+@@ -39,6 +42,7 @@ class Plugin(JPlugin):
+ def importAlbumTags(self,nodeAlbum):
+ """Import tags used in the given image list (IPTC and XMP) and merge them together"""
+ self.showProgress( 0, 1 , _("Importing Tags") )
+- XMPUpdater([nodeAlbum.file]).SyncXmpIptc()
++ #XMPUpdater([nodeAlbum.file]).SyncXmpIptc() needs to be rewritten
++ raise NotImplementedError
+ self.showProgress()
+ return True
diff --git a/jbrout.spec b/jbrout.spec
index 57b7315..5cd67f1 100644
--- a/jbrout.spec
+++ b/jbrout.spec
@@ -3,7 +3,7 @@
Name: jbrout
Version: 0.3.323
%if 0%{?svn_checkout}
-Release: 0.svn323.3
+Release: 0.svn323.4
%else
Release: 2%{?dist}
%endif
@@ -25,6 +25,7 @@ Source5: jbrout-clean-SVN-checkout.sh
Patch0: jbrout-allow-Exif-Orientation-zero.patch
# http://code.google.com/p/jbrout/issues/detail?id=155
Patch1: jbrout-download-plugin.patch
+Patch2: jbrout-eliminate-metadata-exiftool.patch
BuildArch: noarch
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
Requires: python >= 2.4, python-lxml, pygtk2 >= 2.6
@@ -56,7 +57,8 @@ jBrout is able to :
%prep
%setup -q -n %{name}
%patch0 -p1 -b .exifOrientation
-#%patch1 -p1 -b .downloadPlugin
+%patch1 -p1 -b .downloadPlugin
+%patch2 -p1 -b .noExiftool
sh %{SOURCE5}
install -p %{SOURCE1} jbrout/Makefile
install -p -m a+rx,u+w %{SOURCE4} jbrout/install-script
@@ -94,6 +96,9 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/applications/jbrout.desktop
%changelog
+* Tue Jan 04 2011 Matěj Cepl <mcepl at redhat.com> - 0.3.323-0.svn323.4
+- Eliminate exiftool for metadata, make more robust.
+
* Mon Dec 20 2010 Matěj Cepl <mcepl at redhat.com> - 0.3.323-3
- apply patch improving Download plugin (upstream #155)
More information about the scm-commits
mailing list