From: Jason Rumney Date: Mon, 14 Jan 2008 13:20:31 +0000 (+0000) Subject: (image-type): Use image-type-from-file-name (from trunk X-Git-Tag: emacs-pretest-22.1.90~99 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f6f844ab240a51db881a409c1f8449dffc71b487;p=emacs.git (image-type): Use image-type-from-file-name (from trunk 2007-05-21 Chong Yidong ). --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5f19204e0b5..86a9c4dc2ec 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2008-01-14 Jason Rumney + + * image.el (image-type): Use image-type-from-file-name (from trunk + 2007-05-21 Chong Yidong ). + 2008-01-12 Glenn Morris * woman.el (woman-parse-numeric-arg): Change handling of `==': diff --git a/lisp/image.el b/lisp/image.el index 2deaf0a5ebf..d111f7e82a8 100644 --- a/lisp/image.el +++ b/lisp/image.el @@ -313,22 +313,14 @@ use its file extension as image type. Optional DATA-P non-nil means FILE-OR-DATA is a string containing image data." (when (and (not data-p) (not (stringp file-or-data))) (error "Invalid image file name `%s'" file-or-data)) - (cond ((null data-p) - ;; FILE-OR-DATA is a file name. - (unless (or type - (setq type (image-type-from-file-header file-or-data))) - (let ((extension (file-name-extension file-or-data))) - (unless extension - (error "Cannot determine image type")) - (setq type (intern extension))))) - (t - ;; FILE-OR-DATA contains image data. - (unless type - (setq type (image-type-from-data file-or-data))))) (unless type - (error "Cannot determine image type")) - (unless (symbolp type) - (error "Invalid image type `%s'" type)) + (setq type (if data-p + (image-type-from-data file-or-data) + (or (image-type-from-file-header file-or-data) + (image-type-from-file-name file-or-data)))) + (or type(error "Cannot determine image type"))) + (or (memq type (and (boundp 'image-types) image-types)) + (error "Invalid image type `%s'" type)) type)