comparison lisp/image.el @ 38746:0fc8e4a27edc

(image-type-regexps): Allow whitespace at the start of the image data for XPM, XBM and Postscript, which are text files. (image-jpeg-p): Correct computatino of next field offset.
author Gerd Moellmann <gerd@gnu.org>
date Thu, 09 Aug 2001 09:31:56 +0000
parents 24fe4f884e82
children a679a282d5cb
comparison
equal deleted inserted replaced
38745:5464ee1ba8e2 38746:0fc8e4a27edc
29 "Image support." 29 "Image support."
30 :group 'multimedia) 30 :group 'multimedia)
31 31
32 32
33 (defconst image-type-regexps 33 (defconst image-type-regexps
34 '(("\\`/\\*.*XPM.\\*/" . xpm) 34 '(("\\`/[\t\n\r ]*\\*.*XPM.\\*/" . xpm)
35 ("\\`P[1-6]" . pbm) 35 ("\\`P[1-6]" . pbm)
36 ("\\`GIF8" . gif) 36 ("\\`GIF8" . gif)
37 ("\\`\211PNG\r\n" . png) 37 ("\\`\211PNG\r\n" . png)
38 ("\\`#define" . xbm) 38 ("\\`[\t\n\r ]*#define" . xbm)
39 ("\\`\\(MM\0\\*\\)\\|\\(II\\*\0\\)" . tiff) 39 ("\\`\\(MM\0\\*\\)\\|\\(II\\*\0\\)" . tiff)
40 ("\\`%!PS" . postscript) 40 ("\\`[\t\n\r ]*%!PS" . postscript)
41 ("\\`\xff\xd8" . (image-jpeg-p . jpeg))) 41 ("\\`\xff\xd8" . (image-jpeg-p . jpeg)))
42 "Alist of (REGEXP . IMAGE-TYPE) pairs used to auto-detect image types. 42 "Alist of (REGEXP . IMAGE-TYPE) pairs used to auto-detect image types.
43 When the first bytes of an image file match REGEXP, it is assumed to 43 When the first bytes of an image file match REGEXP, it is assumed to
44 be of image type IMAGE-TYPE if IMAGE-TYPE is a symbol. If not a symbol, 44 be of image type IMAGE-TYPE if IMAGE-TYPE is a symbol. If not a symbol,
45 IMAGE-TYPE must be a pair (PREDICATE . TYPE). PREDICATE is called 45 IMAGE-TYPE must be a pair (PREDICATE . TYPE). PREDICATE is called
62 (aref data (+ i 2))))) 62 (aref data (+ i 2)))))
63 (when (= (aref data i) #xe0) 63 (when (= (aref data i) #xe0)
64 ;; APP0 LEN1 LEN2 "JFIF\0" 64 ;; APP0 LEN1 LEN2 "JFIF\0"
65 (throw 'jfif (string-match "\\`\xe0..JFIF\0" 65 (throw 'jfif (string-match "\\`\xe0..JFIF\0"
66 (substring data i (+ i 10))))) 66 (substring data i (+ i 10)))))
67 (setq i (+ i nbytes)))))))) 67 (setq i (+ i 1 nbytes))))))))
68 68
69 69
70 ;;;###autoload 70 ;;;###autoload
71 (defun image-type-from-data (data) 71 (defun image-type-from-data (data)
72 "Determine the image type from image data DATA. 72 "Determine the image type from image data DATA.