aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2017-02-20 13:58:40 +0530
committerArun Isaac2017-02-20 13:58:40 +0530
commit41155280f86a3048d4d09dba83d560436d18f9a9 (patch)
tree0a8a3d942469e87ec50a1421632e82bafd5d1aa7
parent9ea665855b5a04c2c6645e653d197ca1ef456a2c (diff)
downloadexiftool.el-41155280f86a3048d4d09dba83d560436d18f9a9.tar.gz
exiftool.el-41155280f86a3048d4d09dba83d560436d18f9a9.tar.lz
exiftool.el-41155280f86a3048d4d09dba83d560436d18f9a9.zip
Support read/write of multiple tags
* el-exiftool.el (el-exiftool-read): Support reading multiple tags. (el-exiftool-write): Support writing multiple tags. * el-exiftool-tests.el (read-write-test): Accommodate new function prototypes.
-rw-r--r--el-exiftool-tests.el9
-rw-r--r--el-exiftool.el30
2 files changed, 26 insertions, 13 deletions
diff --git a/el-exiftool-tests.el b/el-exiftool-tests.el
index dd6380c..0dd0cc6 100644
--- a/el-exiftool-tests.el
+++ b/el-exiftool-tests.el
@@ -20,10 +20,9 @@
(let ((test-filename "test1.png"))
(let ((temp-filename (make-temp-file "el-exiftool-"
nil (concat "-" test-filename)))
- (tag "xmp:Marked")
- (value "True"))
+ (tag-value-alist '(("Marked" . "True"))))
(copy-file test-filename temp-filename t)
- (el-exiftool-write temp-filename (cons tag value))
- (should (equal (el-exiftool-read temp-filename tag)
- value))
+ (apply 'el-exiftool-write temp-filename tag-value-alist)
+ (should (equal (el-exiftool-read temp-filename (caar tag-value-alist))
+ tag-value-alist))
(delete-file temp-filename))))
diff --git a/el-exiftool.el b/el-exiftool.el
index 61d7630..2e62dfd 100644
--- a/el-exiftool.el
+++ b/el-exiftool.el
@@ -15,6 +15,7 @@
;; You should have received a copy of the GNU General Public License
;; along with el-exiftool. If not, see <http://www.gnu.org/licenses/>.
+(require 'subr)
(require 'subr-x)
(require 'cl)
@@ -41,9 +42,17 @@
"\n-execute\n")
suffix))))))
-(defun el-exiftool-read (filepath tag)
- (el-exiftool-command
- "-s" "-s" "-s" (format "-%s" tag) filepath))
+(defun el-exiftool-read (filepath &rest tags)
+ (mapcar
+ (lambda (line)
+ (apply 'cons (split-string line ": ")))
+ (split-string
+ (apply 'el-exiftool-command
+ "-s" "-s"
+ (append
+ (mapcar (apply-partially 'format "-%s") tags)
+ (list filepath)))
+ "\n+")))
(defun el-exiftool-copy (source destination)
(el-exiftool-command "-overwrite_original"
@@ -52,10 +61,15 @@
(message "Tags from %s copied to %s" source destination)
destination)
-(cl-defun el-exiftool-write (filepath (tag . value))
- (unless (string-blank-p value)
- (el-exiftool-command
- "-m" "-overwrite_original"
- (format "-%s=%s" tag value) filepath)))
+(defun el-exiftool-write (filepath &rest tag-value-alist)
+ (apply 'el-exiftool-command
+ "-m" "-overwrite_original"
+ (append
+ (mapcar
+ (cl-function
+ (lambda ((tag . value))
+ (format "-%s=%s" tag value)))
+ tag-value-alist)
+ (list filepath))))
(provide 'el-exiftool)