;;; image.el --- image API
-;; Copyright (C) 1998-2012 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2013 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: multimedia
"Determine the type of image file FILE from its name.
Value is a symbol specifying the image type, or nil if type cannot
be determined."
- (assoc-default file image-type-file-name-regexps 'string-match-p))
-
+ (let (type first)
+ (catch 'found
+ (dolist (elem image-type-file-name-regexps first)
+ (when (string-match-p (car elem) file)
+ (if (image-type-available-p (setq type (cdr elem)))
+ (throw 'found type)
+ ;; If nothing seems to be supported, return first type that matched.
+ (or first (setq first type))))))))
;;;###autoload
(defun image-type (source &optional type data-p)
"Return non-nil if image type TYPE is available.
Image types are symbols like `xbm' or `jpeg'."
(and (fboundp 'init-image-library)
- (init-image-library type dynamic-library-alist)))
+ (init-image-library type)))
;;;###autoload
"Insert IMAGE into current buffer at point.
IMAGE is displayed by inserting STRING into the current buffer
with a `display' property whose value is the image. STRING
-defaults to the empty string if you omit it.
+defaults to a single space if you omit it.
AREA is where to display the image. AREA nil or omitted means
display it in the text area, a value of `left-margin' means
display it in the left marginal area, a value of `right-margin'
(defun insert-sliced-image (image &optional string area rows cols)
"Insert IMAGE into current buffer at point.
IMAGE is displayed by inserting STRING into the current buffer
-with a `display' property whose value is the image. STRING is
-defaulted if you omit it.
+with a `display' property whose value is the image. The default
+STRING is a single space.
AREA is where to display the image. AREA nil or omitted means
display it in the text area, a value of `left-margin' means
display it in the left marginal area, a value of `right-margin'
(while tail
(setq timer (car tail)
tail (cdr tail))
- (if (and (eq (aref timer 5) 'image-animate-timeout)
- (eq (car-safe (aref timer 6)) image))
+ (if (and (eq (timer--function timer) 'image-animate-timeout)
+ (eq (car-safe (timer--args timer)) image))
(setq tail nil)
(setq timer nil)))
timer))
\f
(defvar imagemagick-types-inhibit)
-(defvar imagemagick-types-enable)
+(defvar imagemagick-enabled-types)
(defun imagemagick-filter-types ()
"Return a list of the ImageMagick types to be treated as images, or nil.
This is the result of `imagemagick-types', including only elements
-that match `imagemagick-types-enable' and do not match
+that match `imagemagick-enabled-types' and do not match
`imagemagick-types-inhibit'."
(when (fboundp 'imagemagick-types)
- (cond ((null imagemagick-types-enable) nil)
+ (cond ((null imagemagick-enabled-types) nil)
((eq imagemagick-types-inhibit t) nil)
- ((eq imagemagick-types-enable t) (imagemagick-types))
(t
(delq nil
(mapcar
(lambda (type)
(unless (memq type imagemagick-types-inhibit)
- (catch 'found
- (dolist (enable imagemagick-types-enable nil)
- (if (cond ((symbolp enable) (eq enable type))
- ((stringp enable)
- (string-match enable (symbol-name type))))
- (throw 'found type))))))
+ (if (eq imagemagick-enabled-types t) type
+ (catch 'found
+ (dolist (enable imagemagick-enabled-types nil)
+ (if (cond ((symbolp enable) (eq enable type))
+ ((stringp enable)
+ (string-match enable
+ (symbol-name type))))
+ (throw 'found type)))))))
(imagemagick-types)))))))
(defvar imagemagick--file-regexp nil
(push (cons re 'image-mode) auto-mode-alist))
(if itfnr-elt
(setcar itfnr-elt re)
- (push (cons re 'imagemagick) image-type-file-name-regexps)))
+ ;; Append to `image-type-file-name-regexps', so that we
+ ;; preferentially use specialized image libraries.
+ (add-to-list 'image-type-file-name-regexps
+ (cons re 'imagemagick) t)))
(setq imagemagick--file-regexp re))))
(defcustom imagemagick-types-inhibit
- '(C HTML HTM TXT PDF)
- "List of ImageMagick types that should not be treated as images.
+ '(C HTML HTM INFO M TXT PDF)
+ "List of ImageMagick types that should never be treated as images.
This should be a list of symbols, each of which should be one of
-the ImageMagick types listed in `imagemagick-types'. The listed
+the ImageMagick types listed by `imagemagick-types'. The listed
image types are not registered by `imagemagick-register-types'.
If the value is t, inhibit the use of ImageMagick for images.
:set (lambda (symbol value)
(set-default symbol value)
(imagemagick-register-types))
- :version "24.1"
+ :version "24.3"
:group 'image)
-(defcustom imagemagick-types-enable
- '("\\`BMP" DJVU "\\`GIF" "\\`ICO" "P?JPE?G" "P[BNP]M"
- "\\`[MP]NG" "\\`TIFF")
+(defcustom imagemagick-enabled-types
+ '(3FR ART ARW AVS BMP BMP2 BMP3 CAL CALS CMYK CMYKA CR2 CRW
+ CUR CUT DCM DCR DCX DDS DJVU DNG DPX EXR FAX FITS GBR GIF
+ GIF87 GRB HRZ ICB ICO ICON J2C JNG JP2 JPC JPEG JPG JPX K25
+ KDC MIFF MNG MRW MSL MSVG MTV NEF ORF OTB PBM PCD PCDS PCL
+ PCT PCX PDB PEF PGM PICT PIX PJPEG PNG PNG24 PNG32 PNG8 PNM
+ PPM PSD PTIF PWP RAF RAS RBG RGB RGBA RGBO RLA RLE SCR SCT
+ SFW SGI SR2 SRF SUN SVG SVGZ TGA TIFF TIFF64 TILE TIM TTF
+ UYVY VDA VICAR VID VIFF VST WBMP WPG X3F XBM XC XCF XPM XV
+ XWD YCbCr YCbCrA YUV)
"List of ImageMagick types to treat as images.
-The list elements are either strings or symbols, and represent
-types returned by `imagemagick-types'. A string is a regexp that
-selects all types matching the regexp.
+Each list element should be a string or symbol, representing one
+of the image types returned by `imagemagick-types'. If the
+element is a string, it is handled as a regexp that enables all
+matching types.
-The value may also be t, meaning all the types that ImageMagick
-supports; or nil, meaning no types.
+The value of `imagemagick-enabled-types' may also be t, meaning
+to enable all types that ImageMagick supports.
The variable `imagemagick-types-inhibit' overrides this variable.
:set (lambda (symbol value)
(set-default symbol value)
(imagemagick-register-types))
- :version "24.2"
+ :version "24.3"
:group 'image)
(imagemagick-register-types)