comparison lisp/image.el @ 38776:a679a282d5cb

(image-jpeg-p): Test for APPn markers in the range #xe0..#xef.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 10 Aug 2001 10:58:33 +0000
parents 0fc8e4a27edc
children 47ae93b5ab9f
comparison
equal deleted inserted replaced
38775:4804dd409fcc 38776:a679a282d5cb
57 (throw 'jfif nil)) 57 (throw 'jfif nil))
58 (setq i (1+ i)) 58 (setq i (1+ i))
59 (when (>= (+ i 2) len) 59 (when (>= (+ i 2) len)
60 (throw 'jfif nil)) 60 (throw 'jfif nil))
61 (let ((nbytes (+ (lsh (aref data (+ i 1)) 8) 61 (let ((nbytes (+ (lsh (aref data (+ i 1)) 8)
62 (aref data (+ i 2))))) 62 (aref data (+ i 2))))
63 (when (= (aref data i) #xe0) 63 (code (aref data i)))
64 (when (and (>= code #xe0) (<= code #xef))
64 ;; APP0 LEN1 LEN2 "JFIF\0" 65 ;; APP0 LEN1 LEN2 "JFIF\0"
65 (throw 'jfif (string-match "\\`\xe0..JFIF\0" 66 (throw 'jfif
66 (substring data i (+ i 10))))) 67 (string-match "JFIF" (substring data i nbytes))))
67 (setq i (+ i 1 nbytes)))))))) 68 (setq i (+ i 1 nbytes))))))))
68 69
69 70
70 ;;;###autoload 71 ;;;###autoload
71 (defun image-type-from-data (data) 72 (defun image-type-from-data (data)