Paul Pogonyshev <pogonyshev at gmx.net>
[bpt/emacs.git] / lisp / image.el
CommitLineData
7840ced1
GM
1;;; image.el --- image API
2
0d30b337 3;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
d7a0267c 4;; 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
634f4a67
PJ
5
6;; Maintainer: FSF
04799cf5 7;; Keywords: multimedia
7840ced1
GM
8
9;; This file is part of GNU Emacs.
10
11;; GNU Emacs is free software; you can redistribute it and/or modify
12;; it under the terms of the GNU General Public License as published by
b4aa6026 13;; the Free Software Foundation; either version 3, or (at your option)
7840ced1
GM
14;; any later version.
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
22;; along with GNU Emacs; see the file COPYING. If not, write to the
086add15
LK
23;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24;; Boston, MA 02110-1301, USA.
7840ced1
GM
25
26;;; Commentary:
27
28;;; Code:
29
77f6105c
MB
30
31(defgroup image ()
32 "Image support."
33 :group 'multimedia)
34
35
4fde92ef 36(defconst image-type-header-regexps
6642c904
JB
37 '(("\\`/[\t\n\r ]*\\*.*XPM.\\*/" . xpm)
38 ("\\`P[1-6][[:space:]]+\\(?:#.*[[:space:]]+\\)*[0-9]+[[:space:]]+[0-9]+" . pbm)
3205431d 39 ("\\`GIF8[79]a" . gif)
6642c904 40 ("\\`\x89PNG\r\n\x1a\n" . png)
2dca7106
RS
41 ("\\`[\t\n\r ]*#define \\([a-z0-9]+\\)_width [0-9]+\n\
42#define \\1_height [0-9]+\n\
43static char \\1_bits" . xbm)
6642c904
JB
44 ("\\`\\(?:MM\0\\*\\|II\\*\0\\)" . tiff)
45 ("\\`[\t\n\r ]*%!PS" . postscript)
46 ("\\`\xff\xd8" . (image-jpeg-p . jpeg)))
47 "Alist of (REGEXP . IMAGE-TYPE) pairs used to auto-detect image types.
7840ced1 48When the first bytes of an image file match REGEXP, it is assumed to
6642c904
JB
49be of image type IMAGE-TYPE if IMAGE-TYPE is a symbol. If not a symbol,
50IMAGE-TYPE must be a pair (PREDICATE . TYPE). PREDICATE is called
51with one argument, a string containing the image data. If PREDICATE returns
52a non-nil value, TYPE is the image's type.")
8a8ef149 53
4fde92ef
KS
54(defconst image-type-file-name-regexps
55 '(("\\.png\\'" . png)
56 ("\\.gif\\'" . gif)
57 ("\\.jpe?g\\'" . jpeg)
58 ("\\.bmp\\'" . bmp)
59 ("\\.xpm\\'" . xpm)
60 ("\\.pbm\\'" . pbm)
61 ("\\.xbm\\'" . xbm)
62 ("\\.ps\\'" . postscript)
63 ("\\.tiff?\\'" . tiff))
64 "Alist of (REGEXP . IMAGE-TYPE) pairs used to identify image files.
65When the name of an image file match REGEXP, it is assumed to
66be of image type IMAGE-TYPE.")
67
a9bb04bb
CY
68;; We rely on `auto-mode-alist' to detect xbm and xpm files, instead
69;; of content autodetection. Their contents are just C code, so it is
70;; easy to generate false matches.
6642c904
JB
71(defvar image-type-auto-detectable
72 '((pbm . t)
a9bb04bb 73 (xbm . nil)
6642c904
JB
74 (bmp . maybe)
75 (gif . maybe)
76 (png . maybe)
a9bb04bb 77 (xpm . nil)
6642c904
JB
78 (jpeg . maybe)
79 (tiff . maybe)
80 (postscript . nil))
81 "Alist of (IMAGE-TYPE . AUTODETECT) pairs used to auto-detect image files.
82\(See `image-type-auto-detected-p').
83
84AUTODETECT can be
85 - t always auto-detect.
86 - nil never auto-detect.
87 - maybe auto-detect only if the image type is available
88 (see `image-type-available-p').")
4fde92ef 89
dada660a 90(defvar image-load-path nil
5fc5ac38 91 "List of locations in which to search for image files.
93a75651
CY
92If an element is a string, it defines a directory to search.
93If an element is a variable symbol whose value is a string, that
94value defines a directory to search.
95If an element is a variable symbol whose value is a list, the
96value is used as a list of directories to search.")
5fc5ac38 97
dada660a
RS
98(eval-at-startup
99 (setq image-load-path
100 (list (file-name-as-directory (expand-file-name "images" data-directory))
101 'data-directory 'load-path)))
102
5248a565 103
20c65d08 104(defun image-load-path-for-library (library image &optional path no-error)
ae77c7ff 105 "Return a suitable search path for images used by LIBRARY.
7c565097 106
40db64d2 107It searches for IMAGE in `image-load-path' (excluding
c0696e1b
BW
108\"`data-directory'/images\") and `load-path', followed by a path
109suitable for LIBRARY, which includes \"../../etc/images\" and
110\"../etc/images\" relative to the library file itself, and then
111in \"`data-directory'/images\".
7c565097 112
5248a565
BW
113Then this function returns a list of directories which contains
114first the directory in which IMAGE was found, followed by the
115value of `load-path'. If PATH is given, it is used instead of
116`load-path'.
20c65d08 117
5248a565
BW
118If NO-ERROR is non-nil and a suitable path can't be found, don't
119signal an error. Instead, return a list of directories as before,
120except that nil appears in place of the image directory.
7c565097
BW
121
122Here is an example that uses a common idiom to provide
123compatibility with versions of Emacs that lack the variable
124`image-load-path':
125
9f036d33
BW
126 ;; Shush compiler.
127 (defvar image-load-path)
5248a565
BW
128
129 (let* ((load-path (image-load-path-for-library \"mh-e\" \"mh-logo.xpm\"))
9f036d33
BW
130 (image-load-path (cons (car load-path)
131 (when (boundp 'image-load-path)
132 image-load-path))))
5248a565 133 (mh-tool-bar-folder-buttons-init))"
7c565097
BW
134 (unless library (error "No library specified"))
135 (unless image (error "No image specified"))
c0696e1b
BW
136 (let (image-directory image-directory-load-path)
137 ;; Check for images in image-load-path or load-path.
138 (let ((img image)
139 (dir (or
140 ;; Images in image-load-path.
141 (image-search-load-path image)
142 ;; Images in load-path.
143 (locate-library image)))
144 parent)
145 ;; Since the image might be in a nested directory (for
146 ;; example, mail/attach.pbm), adjust `image-directory'
147 ;; accordingly.
148 (when dir
149 (setq dir (file-name-directory dir))
150 (while (setq parent (file-name-directory img))
151 (setq img (directory-file-name parent)
152 dir (expand-file-name "../" dir))))
153 (setq image-directory-load-path dir))
154
155 ;; If `image-directory-load-path' isn't Emacs' image directory,
156 ;; it's probably a user preference, so use it. Then use a
157 ;; relative setting if possible; otherwise, use
158 ;; `image-directory-load-path'.
7c565097 159 (cond
c0696e1b
BW
160 ;; User-modified image-load-path?
161 ((and image-directory-load-path
162 (not (equal image-directory-load-path
163 (file-name-as-directory
164 (expand-file-name "images" data-directory)))))
165 (setq image-directory image-directory-load-path))
7c565097
BW
166 ;; Try relative setting.
167 ((let (library-name d1ei d2ei)
168 ;; First, find library in the load-path.
169 (setq library-name (locate-library library))
170 (if (not library-name)
171 (error "Cannot find library %s in load-path" library))
172 ;; And then set image-directory relative to that.
173 (setq
174 ;; Go down 2 levels.
c0696e1b
BW
175 d2ei (file-name-as-directory
176 (expand-file-name
177 (concat (file-name-directory library-name) "../../etc/images")))
7c565097 178 ;; Go down 1 level.
c0696e1b
BW
179 d1ei (file-name-as-directory
180 (expand-file-name
181 (concat (file-name-directory library-name) "../etc/images"))))
7c565097
BW
182 (setq image-directory
183 ;; Set it to nil if image is not found.
184 (cond ((file-exists-p (expand-file-name image d2ei)) d2ei)
185 ((file-exists-p (expand-file-name image d1ei)) d1ei)))))
c0696e1b
BW
186 ;; Use Emacs' image directory.
187 (image-directory-load-path
188 (setq image-directory image-directory-load-path))
20c65d08 189 (no-error
20c65d08 190 (message "Could not find image %s for library %s" image library))
7c565097
BW
191 (t
192 (error "Could not find image %s for library %s" image library)))
193
5248a565
BW
194 ;; Return an augmented `path' or `load-path'.
195 (nconc (list image-directory)
196 (delete image-directory (copy-sequence (or path load-path))))))
197
7c565097 198
8a8ef149 199(defun image-jpeg-p (data)
9b78a6a3
RS
200 "Value is non-nil if DATA, a string, consists of JFIF image data.
201We accept the tag Exif because that is the same format."
8a8ef149
GM
202 (when (string-match "\\`\xff\xd8" data)
203 (catch 'jfif
204 (let ((len (length data)) (i 2))
205 (while (< i len)
206 (when (/= (aref data i) #xff)
207 (throw 'jfif nil))
208 (setq i (1+ i))
209 (when (>= (+ i 2) len)
210 (throw 'jfif nil))
211 (let ((nbytes (+ (lsh (aref data (+ i 1)) 8)
4a9bf8a4
GM
212 (aref data (+ i 2))))
213 (code (aref data i)))
214 (when (and (>= code #xe0) (<= code #xef))
8a8ef149 215 ;; APP0 LEN1 LEN2 "JFIF\0"
71296446 216 (throw 'jfif
32b3c766
JPW
217 (string-match "JFIF\\|Exif"
218 (substring data i (min (+ i nbytes) len)))))
3bdbead3 219 (setq i (+ i 1 nbytes))))))))
7840ced1
GM
220
221
222;;;###autoload
162dec01
GM
223(defun image-type-from-data (data)
224 "Determine the image type from image data DATA.
225Value is a symbol specifying the image type or nil if type cannot
7840ced1 226be determined."
4fde92ef 227 (let ((types image-type-header-regexps)
7840ced1 228 type)
4fde92ef 229 (while types
7840ced1 230 (let ((regexp (car (car types)))
6642c904 231 (image-type (cdr (car types))))
4fde92ef
KS
232 (if (or (and (symbolp image-type)
233 (string-match regexp data))
234 (and (consp image-type)
235 (funcall (car image-type) data)
236 (setq image-type (cdr image-type))))
237 (setq type image-type
238 types nil)
239 (setq types (cdr types)))))
240 type))
241
242
243;;;###autoload
6642c904 244(defun image-type-from-buffer ()
4fde92ef 245 "Determine the image type from data in the current buffer.
6642c904
JB
246Value is a symbol specifying the image type or nil if type cannot
247be determined."
4fde92ef
KS
248 (let ((types image-type-header-regexps)
249 type
250 (opoint (point)))
251 (goto-char (point-min))
252 (while types
253 (let ((regexp (car (car types)))
6642c904 254 (image-type (cdr (car types)))
4fde92ef
KS
255 data)
256 (if (or (and (symbolp image-type)
257 (looking-at regexp))
258 (and (consp image-type)
259 (funcall (car image-type)
260 (or data
261 (setq data
262 (buffer-substring
263 (point-min)
264 (min (point-max)
265 (+ (point-min) 256))))))
266 (setq image-type (cdr image-type))))
6642c904 267 (setq type image-type
4fde92ef
KS
268 types nil)
269 (setq types (cdr types)))))
270 (goto-char opoint)
7840ced1
GM
271 type))
272
273
162dec01
GM
274;;;###autoload
275(defun image-type-from-file-header (file)
276 "Determine the type of image file FILE from its first few bytes.
277Value is a symbol specifying the image type, or nil if type cannot
278be determined."
4fde92ef
KS
279 (unless (or (file-readable-p file)
280 (file-name-absolute-p file))
281 (setq file (image-search-load-path file)))
282 (and file
283 (file-readable-p file)
284 (with-temp-buffer
285 (set-buffer-multibyte nil)
286 (insert-file-contents-literally file nil 0 256)
6642c904 287 (image-type-from-buffer))))
4fde92ef
KS
288
289
290;;;###autoload
291(defun image-type-from-file-name (file)
292 "Determine the type of image file FILE from its name.
293Value is a symbol specifying the image type, or nil if type cannot
294be determined."
7d88e015 295 (assoc-default file image-type-file-name-regexps 'string-match))
162dec01
GM
296
297
7840ced1 298;;;###autoload
7d88e015 299(defun image-type (source &optional type data-p)
e7968373 300 "Determine and return image type.
7d88e015 301SOURCE is an image file name or image data.
7840ced1 302Optional TYPE is a symbol describing the image type. If TYPE is omitted
162dec01 303or nil, try to determine the image type from its first few bytes
7d88e015 304of image data. If that doesn't work, and SOURCE is a file name,
9ea8de1b 305use its file extension as image type.
7d88e015
CY
306Optional DATA-P non-nil means SOURCE is a string containing image data."
307 (when (and (not data-p) (not (stringp source)))
308 (error "Invalid image file name `%s'" source))
162dec01 309 (unless type
7d88e015
CY
310 (setq type (if data-p
311 (image-type-from-data source)
312 (or (image-type-from-file-header source)
313 (image-type-from-file-name source))))
314 (or type (error "Cannot determine image type")))
315 (or (memq type image-types)
316 (error "Invalid image type `%s'" type))
e7968373
KS
317 type)
318
6642c904 319
e7968373
KS
320;;;###autoload
321(defun image-type-available-p (type)
322 "Return non-nil if image type TYPE is available.
323Image types are symbols like `xbm' or `jpeg'."
324 (and (fboundp 'init-image-library)
325 (init-image-library type image-library-alist)))
326
327
6642c904
JB
328;;;###autoload
329(defun image-type-auto-detected-p ()
4837b516 330 "Return t if the current buffer contains an auto-detectable image.
7d88e015
CY
331This function is intended to be used from `magic-fallback-mode-alist'.
332
333The buffer is considered to contain an auto-detectable image if
334its beginning matches an image type in `image-type-header-regexps',
335and that image type is present in `image-type-auto-detectable'."
6642c904
JB
336 (let* ((type (image-type-from-buffer))
337 (auto (and type (cdr (assq type image-type-auto-detectable)))))
7d88e015
CY
338 (and type
339 (or (eq auto t) (image-type-available-p type)))))
6642c904
JB
340
341
e7968373
KS
342;;;###autoload
343(defun create-image (file-or-data &optional type data-p &rest props)
344 "Create an image.
345FILE-OR-DATA is an image file name or image data.
346Optional TYPE is a symbol describing the image type. If TYPE is omitted
347or nil, try to determine the image type from its first few bytes
348of image data. If that doesn't work, and FILE-OR-DATA is a file name,
349use its file extension as image type.
350Optional DATA-P non-nil means FILE-OR-DATA is a string containing image data.
351Optional PROPS are additional image attributes to assign to the image,
352like, e.g. `:mask MASK'.
353Value is the image created, or nil if images of type TYPE are not supported.
354
355Images should not be larger than specified by `max-image-size'."
356 (setq type (image-type file-or-data type data-p))
7840ced1 357 (when (image-type-available-p type)
162dec01
GM
358 (append (list 'image :type type (if data-p :data :file) file-or-data)
359 props)))
7840ced1
GM
360
361
362;;;###autoload
cedbd8d0 363(defun put-image (image pos &optional string area)
1571b5ff 364 "Put image IMAGE in front of POS in the current buffer.
7840ced1 365IMAGE must be an image created with `create-image' or `defimage'.
46655c94
GM
366IMAGE is displayed by putting an overlay into the current buffer with a
367`before-string' STRING that has a `display' property whose value is the
cedbd8d0 368image. STRING is defaulted if you omit it.
7840ced1 369POS may be an integer or marker.
7840ced1
GM
370AREA is where to display the image. AREA nil or omitted means
371display it in the text area, a value of `left-margin' means
372display it in the left marginal area, a value of `right-margin'
46655c94 373means display it in the right marginal area."
0ad550ba 374 (unless string (setq string "x"))
1571b5ff 375 (let ((buffer (current-buffer)))
cedbd8d0 376 (unless (eq (car-safe image) 'image)
1571b5ff
GM
377 (error "Not an image: %s" image))
378 (unless (or (null area) (memq area '(left-margin right-margin)))
379 (error "Invalid area %s" area))
46655c94 380 (setq string (copy-sequence string))
1571b5ff 381 (let ((overlay (make-overlay pos pos buffer))
46655c94
GM
382 (prop (if (null area) image (list (list 'margin area) image))))
383 (put-text-property 0 (length string) 'display prop string)
1571b5ff
GM
384 (overlay-put overlay 'put-image t)
385 (overlay-put overlay 'before-string string))))
7840ced1
GM
386
387
388;;;###autoload
5af275e0 389(defun insert-image (image &optional string area slice)
7840ced1 390 "Insert IMAGE into current buffer at point.
46655c94 391IMAGE is displayed by inserting STRING into the current buffer
cedbd8d0
DL
392with a `display' property whose value is the image. STRING is
393defaulted if you omit it.
7840ced1
GM
394AREA is where to display the image. AREA nil or omitted means
395display it in the text area, a value of `left-margin' means
396display it in the left marginal area, a value of `right-margin'
5af275e0
KS
397means display it in the right marginal area.
398SLICE specifies slice of IMAGE to insert. SLICE nil or omitted
399means insert whole image. SLICE is a list (X Y WIDTH HEIGHT)
400specifying the X and Y positions and WIDTH and HEIGHT of image area
401to insert. A float value 0.0 - 1.0 means relative to the width or
402height of the image; integer values are taken as pixel values."
0ad550ba
DL
403 ;; Use a space as least likely to cause trouble when it's a hidden
404 ;; character in the buffer.
405 (unless string (setq string " "))
cedbd8d0 406 (unless (eq (car-safe image) 'image)
7840ced1
GM
407 (error "Not an image: %s" image))
408 (unless (or (null area) (memq area '(left-margin right-margin)))
409 (error "Invalid area %s" area))
0dc91c57
DL
410 (if area
411 (setq image (list (list 'margin area) image))
412 ;; Cons up a new spec equal but not eq to `image' so that
413 ;; inserting it twice in a row (adjacently) displays two copies of
414 ;; the image. Don't try to avoid this by looking at the display
415 ;; properties on either side so that we DTRT more often with
416 ;; cut-and-paste. (Yanking killed image text next to another copy
417 ;; of it loses anyway.)
418 (setq image (cons 'image (cdr image))))
46655c94
GM
419 (let ((start (point)))
420 (insert string)
421 (add-text-properties start (point)
5af275e0
KS
422 `(display ,(if slice
423 (list (cons 'slice slice) image)
424 image) rear-nonsticky (display)))))
425
426
f22c36d3 427;;;###autoload
5af275e0 428(defun insert-sliced-image (image &optional string area rows cols)
b48bc937
KS
429 "Insert IMAGE into current buffer at point.
430IMAGE is displayed by inserting STRING into the current buffer
431with a `display' property whose value is the image. STRING is
432defaulted if you omit it.
433AREA is where to display the image. AREA nil or omitted means
434display it in the text area, a value of `left-margin' means
435display it in the left marginal area, a value of `right-margin'
436means display it in the right marginal area.
437The image is automatically split into ROW x COLS slices."
5af275e0
KS
438 (unless string (setq string " "))
439 (unless (eq (car-safe image) 'image)
440 (error "Not an image: %s" image))
441 (unless (or (null area) (memq area '(left-margin right-margin)))
442 (error "Invalid area %s" area))
443 (if area
444 (setq image (list (list 'margin area) image))
445 ;; Cons up a new spec equal but not eq to `image' so that
446 ;; inserting it twice in a row (adjacently) displays two copies of
447 ;; the image. Don't try to avoid this by looking at the display
448 ;; properties on either side so that we DTRT more often with
449 ;; cut-and-paste. (Yanking killed image text next to another copy
450 ;; of it loses anyway.)
451 (setq image (cons 'image (cdr image))))
452 (let ((x 0.0) (dx (/ 1.0001 (or cols 1)))
453 (y 0.0) (dy (/ 1.0001 (or rows 1))))
454 (while (< y 1.0)
455 (while (< x 1.0)
456 (let ((start (point)))
457 (insert string)
458 (add-text-properties start (point)
459 `(display ,(list (list 'slice x y dx dy) image)
460 rear-nonsticky (display)))
461 (setq x (+ x dx))))
462 (setq x 0.0
463 y (+ y dy))
82dc617b 464 (insert (propertize "\n" 'line-height t)))))
5af275e0 465
10e2102e 466
7840ced1
GM
467
468;;;###autoload
469(defun remove-images (start end &optional buffer)
470 "Remove images between START and END in BUFFER.
471Remove only images that were put in BUFFER with calls to `put-image'.
472BUFFER nil or omitted means use the current buffer."
473 (unless buffer
474 (setq buffer (current-buffer)))
475 (let ((overlays (overlays-in start end)))
476 (while overlays
477 (let ((overlay (car overlays)))
478 (when (overlay-get overlay 'put-image)
0c898dd9
DL
479 (delete-overlay overlay)))
480 (setq overlays (cdr overlays)))))
7840ced1 481
4fde92ef
KS
482(defun image-search-load-path (file &optional path)
483 (unless path
484 (setq path image-load-path))
485 (let (element found filename)
5fc5ac38 486 (while (and (not found) (consp path))
93a75651 487 (setq element (car path))
5fc5ac38 488 (cond
93a75651 489 ((stringp element)
5fc5ac38
CY
490 (setq found
491 (file-readable-p
4fde92ef 492 (setq filename (expand-file-name file element)))))
93a75651
CY
493 ((and (symbolp element) (boundp element))
494 (setq element (symbol-value element))
495 (cond
496 ((stringp element)
497 (setq found
498 (file-readable-p
4fde92ef 499 (setq filename (expand-file-name file element)))))
93a75651 500 ((consp element)
4fde92ef 501 (if (setq filename (image-search-load-path file element))
93a75651 502 (setq found t))))))
5fc5ac38 503 (setq path (cdr path)))
4fde92ef 504 (if found filename)))
7840ced1
GM
505
506;;;###autoload
349c034d
GM
507(defun find-image (specs)
508 "Find an image, choosing one of a list of image specifications.
7840ced1 509
cedbd8d0 510SPECS is a list of image specifications.
7840ced1
GM
511
512Each image specification in SPECS is a property list. The contents of
513a specification are image type dependent. All specifications must at
bc283707
WP
514least contain the properties `:type TYPE' and either `:file FILE' or
515`:data DATA', where TYPE is a symbol specifying the image type,
516e.g. `xbm', FILE is the file to load the image from, and DATA is a
cedbd8d0
DL
517string containing the actual image data. The specification whose TYPE
518is supported, and FILE exists, is used to construct the image
519specification to be returned. Return nil if no specification is
520satisfied.
521
8646a62e
CY
522The image is looked for in `image-load-path'.
523
524Image files should not be larger than specified by `max-image-size'."
7840ced1
GM
525 (let (image)
526 (while (and specs (null image))
527 (let* ((spec (car specs))
528 (type (plist-get spec :type))
162dec01 529 (data (plist-get spec :data))
7f228379
GM
530 (file (plist-get spec :file))
531 found)
162dec01
GM
532 (when (image-type-available-p type)
533 (cond ((stringp file)
4fde92ef 534 (if (setq found (image-search-load-path file))
5fc5ac38
CY
535 (setq image
536 (cons 'image (plist-put (copy-sequence spec)
537 :file found)))))
f64ae86c 538 ((not (null data))
162dec01
GM
539 (setq image (cons 'image spec)))))
540 (setq specs (cdr specs))))
349c034d
GM
541 image))
542
543
544;;;###autoload
545(defmacro defimage (symbol specs &optional doc)
546 "Define SYMBOL as an image.
547
548SPECS is a list of image specifications. DOC is an optional
549documentation string.
550
551Each image specification in SPECS is a property list. The contents of
552a specification are image type dependent. All specifications must at
553least contain the properties `:type TYPE' and either `:file FILE' or
554`:data DATA', where TYPE is a symbol specifying the image type,
555e.g. `xbm', FILE is the file to load the image from, and DATA is a
556string containing the actual image data. The first image
557specification whose TYPE is supported, and FILE exists, is used to
558define SYMBOL.
559
560Example:
561
562 (defimage test-image ((:type xpm :file \"~/test1.xpm\")
563 (:type xbm :file \"~/test1.xbm\")))"
fd8e7a80 564 (declare (doc-string 3))
349c034d 565 `(defvar ,symbol (find-image ',specs) ,doc))
7840ced1
GM
566
567
568(provide 'image)
569
fd8e7a80 570;; arch-tag: 8e76a07b-eb48-4f3e-a7a0-1a7ba9f096b3
e43367a0 571;;; image.el ends here