image: improving xmp support
authorFredrik Unger <fred@tree.se>
Tue, 22 Jan 2019 19:47:03 +0000 (20:47 +0100)
committerFredrik Unger <fred@tree.se>
Tue, 22 Jan 2019 19:47:03 +0000 (20:47 +0100)
Adding some new support for writing resized files, pusing the
caption to thouse files. Returning if False if xmp is missing.

treecutter/image.py

index d031e2650a26ec7f6fc2d172db5288e1b54c241f..6136a0d62fcd81a5ad65da48c7db84027ba4f3e7 100644 (file)
@@ -51,6 +51,12 @@ class Image():
                     if retcode:
                         print 'Error: '+' '.join(cmd)+' Returncode ['+str(retcode)+']'
                         exit
+            else:
+                cmd = ['exiftool', '-XMP:CreatorTool=treecutter','-quiet','-overwrite_original', outfile]
+                retcode = subprocess.call(cmd)
+                if retcode:
+                    print 'Error: '+' '.join(cmd)+' Returncode ['+str(retcode)+']'
+                    exit
             xmpfile.close_file()
             self._format[size] = outfile
         return outfile
@@ -58,6 +64,8 @@ class Image():
     def generated(self):
         xmpfile = XMPFiles(file_path=self._filename)
         xmp = xmpfile.get_xmp()
+        if not xmp:
+            return False
         cr = None
         if xmp.does_property_exist(consts.XMP_NS_XMP, u'CreatorTool'):
             cr = xmp.get_property(consts.XMP_NS_XMP, u'CreatorTool')