X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/3bdbead3dd7391c6198c6be03c4c787ac80dee85..c45bb3b1174811090f907bdda4ff257546f55815:/lisp/image.el diff --git a/lisp/image.el b/lisp/image.el index 3e61b100ce..ac1ef557ed 100644 --- a/lisp/image.el +++ b/lisp/image.el @@ -1,6 +1,8 @@ ;;; image.el --- image API ;; Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + +;; Maintainer: FSF ;; Keywords: multimedia ;; This file is part of GNU Emacs. @@ -36,7 +38,7 @@ ("\\`GIF8" . gif) ("\\`\211PNG\r\n" . png) ("\\`[\t\n\r ]*#define" . xbm) - ("\\`\\(MM\0\\*\\)\\|\\(II\\*\0\\)" . tiff) + ("\\`\\(MM\0\\*\\|II\\*\0\\)" . tiff) ("\\`[\t\n\r ]*%!PS" . postscript) ("\\`\xff\xd8" . (image-jpeg-p . jpeg))) "Alist of (REGEXP . IMAGE-TYPE) pairs used to auto-detect image types. @@ -48,7 +50,8 @@ a non-nil value, TYPE is the image's type ") (defun image-jpeg-p (data) - "Value is non-nil if DATA, a string, consists of JFIF image data." + "Value is non-nil if DATA, a string, consists of JFIF image data. +We accept the tag Exif because that is the same format." (when (string-match "\\`\xff\xd8" data) (catch 'jfif (let ((len (length data)) (i 2)) @@ -59,11 +62,12 @@ a non-nil value, TYPE is the image's type ") (when (>= (+ i 2) len) (throw 'jfif nil)) (let ((nbytes (+ (lsh (aref data (+ i 1)) 8) - (aref data (+ i 2))))) - (when (= (aref data i) #xe0) + (aref data (+ i 2)))) + (code (aref data i))) + (when (and (>= code #xe0) (<= code #xef)) ;; APP0 LEN1 LEN2 "JFIF\0" - (throw 'jfif (string-match "\\`\xe0..JFIF\0" - (substring data i (+ i 10))))) + (throw 'jfif + (string-match "JFIF\\|Exif" (substring data i (+ i nbytes))))) (setq i (+ i 1 nbytes)))))))) @@ -96,6 +100,7 @@ be determined." (setq file (expand-file-name file data-directory))) (setq file (expand-file-name file)) (let ((header (with-temp-buffer + (set-buffer-multibyte nil) (insert-file-contents-literally file nil 0 256) (buffer-string)))) (image-type-from-data header))) @@ -198,11 +203,7 @@ means display it in the right marginal area." (let ((start (point))) (insert string) (add-text-properties start (point) - (list 'display image - ;; `image' has the right properties to - ;; mark an intangible field. - 'intangible image - 'rear-nonsticky (list 'display))))) + `(display ,image rear-nonsticky (display))))) ;;;###autoload