From 5680faad8fdf81cc14e7e7023b61854839931aae Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Fri, 14 Aug 2020 13:53:09 +0200 Subject: [PATCH] Allow doc-view.el to rescale without imagemagick support * lisp/doc-view.el (doc-view-mode-p, doc-view-enlarge) (doc-view-scale-reset, doc-view-insert-image): Remove checks for imagemagick (bug#42272) -- Emacs can rescale images without imagemagick. --- lisp/doc-view.el | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lisp/doc-view.el b/lisp/doc-view.el index de342f1519e..3e2b2443260 100644 --- a/lisp/doc-view.el +++ b/lisp/doc-view.el @@ -740,8 +740,7 @@ It's a subdirectory of `doc-view-cache-directory'." Document types are symbols like `dvi', `ps', `pdf', or `odf' (any OpenDocument format)." (and (display-graphic-p) - (or (image-type-available-p 'imagemagick) - (image-type-available-p 'png)) + (image-type-available-p 'png) (cond ((eq type 'dvi) (and (doc-view-mode-p 'pdf) @@ -769,10 +768,7 @@ OpenDocument format)." (defun doc-view-enlarge (factor) "Enlarge the document by FACTOR." (interactive (list doc-view-shrink-factor)) - (if (and doc-view-scale-internally - (eq (plist-get (cdr (doc-view-current-image)) :type) - 'imagemagick)) - ;; ImageMagick supports on-the-fly-rescaling. + (if doc-view-scale-internally (let ((new (ceiling (* factor doc-view-image-width)))) (unless (equal new doc-view-image-width) (setq-local doc-view-image-width new) @@ -792,9 +788,7 @@ OpenDocument format)." (defun doc-view-scale-reset () "Reset the document size/zoom level to the initial one." (interactive) - (if (and doc-view-scale-internally - (eq (plist-get (cdr (doc-view-current-image)) :type) - 'imagemagick)) + (if doc-view-scale-internally (progn (kill-local-variable 'doc-view-image-width) (doc-view-insert-image @@ -1393,12 +1387,11 @@ ARGS is a list of image descriptors." ;; Only insert the image if the buffer is visible. (when (window-live-p (overlay-get ol 'window)) (let* ((image (if (and file (file-readable-p file)) - (if (not (and doc-view-scale-internally - (fboundp 'imagemagick-types))) + (if (not doc-view-scale-internally) (apply #'create-image file doc-view--image-type nil args) (unless (member :width args) (setq args `(,@args :width ,doc-view-image-width))) - (apply #'create-image file 'imagemagick nil args)))) + (apply #'create-image file doc-view--image-type nil args)))) (slice (doc-view-current-slice)) (img-width (and image (car (image-size image)))) (displayed-img-width (if (and image slice) -- 2.39.5