summaryrefslogtreecommitdiff
path: root/lisp/image
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2020-03-19 16:15:04 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2020-03-19 16:15:24 +0100
commit0128375a50352720c626fd915312a5c38762d09a (patch)
tree4b9ebf701674a837c7f523c13c9001dca8dbabc3 /lisp/image
parentd98afc1019d9f177dd05042371dd8239b7901d47 (diff)
downloademacs-0128375a50352720c626fd915312a5c38762d09a.tar.gz
Don't have exif bugging out on short strings
* lisp/image/exif.el (exif--direct-ascii-value): New function (bug#40127). (exif--parse-directory): Use it to get the correct values for in-directory (i.e., shorter than 4 octets) strings.
Diffstat (limited to 'lisp/image')
-rw-r--r--lisp/image/exif.el21
1 files changed, 19 insertions, 2 deletions
diff --git a/lisp/image/exif.el b/lisp/image/exif.el
index 642bc58321c..065456dc318 100644
--- a/lisp/image/exif.el
+++ b/lisp/image/exif.el
@@ -72,7 +72,8 @@
(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
@@ -216,7 +217,10 @@ If the orientation isn't present in the data, return nil."
(+ (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)))
@@ -231,6 +235,19 @@ If the orientation isn't present in the data, return nil."
;; 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