(283 y-resolution)
(296 resolution-unit)
(305 software)
- (306 date-time))
+ (306 date-time)
+ (315 artist))
"Alist of tag values and their names.")
(defconst exif--orientation
(+ (1+ value) length)))
;; The value is stored directly
;; in the directory.
- value)
+ (if (eq (car field-format) 'ascii)
+ (exif--direct-ascii-value
+ value (1- length) le)
+ value))
(car field-format)
le)))))
(let ((next (exif--read-number 4 le)))
;; We've reached the end of the directories.
dir))))
+(defun exif--direct-ascii-value (value bytes le)
+ "Make VALUE into a zero-terminated string.
+VALUE is an integer representing BYTES characters."
+ (with-temp-buffer
+ (set-buffer-multibyte nil)
+ (if le
+ (dotimes (i bytes)
+ (insert (logand (lsh value (* i -8)) 255)))
+ (dotimes (i bytes)
+ (insert (logand (lsh value (* (- (1- bytes) i) -8)) 255))))
+ (insert 0)
+ (buffer-string)))
+
(defun exif--process-value (value type le)
"Do type-based post-processing of the value."
(cl-case type
(should (equal (exif-elem exif 'orientation) 1))
(should (equal (exif-elem exif 'x-resolution) '(180 . 1)))))
+(ert-deftest test-exif-parse-short ()
+ (let ((exif (exif-parse-file (test-image-file "black-short.jpg"))))
+ (should (equal (exif-elem exif 'make) "thr"))
+ (should (equal (exif-elem exif 'model) "four"))
+ (should (equal (exif-elem exif 'software) "em"))
+ (should (equal (exif-elem exif 'artist) "z"))))
+
+(ert-deftest test-exit-direct-ascii-value ()
+ (equal (exif--direct-ascii-value 28005 2 t) (string ?e ?m 0))
+ (equal (exif--direct-ascii-value 28005 2 nil) (string ?m ?e 0)))
+
;;; exif-tests.el ends here