emacs image display zoom


On Feb 25, 4:48 am, Sébastien Vauban wrote:
> Hello,
> I view more and more image files from within Emacs, be it from a
> Dired buffer, or as an attachment in a mail that I view in Gnus.
> My problem is: how can we zoom (out, mainly) the picture?
> It doesn't seem to be any way to do so in the `image-mode'.
> Though, it should be possible as similar functions already have
> been implemented for the `doc-view' package. Is there a package
> I should know of, that would take care of adding zooming
> commands when viewing buffers with pictures?

i have no idea how zoom can be implemented as shown in typical image viewers. I suppose it's recompute the bitmap and redisplay.

Note that in many browsers, Opera for example, you can zoom the whole page. (i.e. not the same as changing font size) This feature is in Mathematica IDE too (aka Frontend), since early 1990s.

i doubt this feature could easily fit into emacs, probably require huge coding effort to its core.

as a workaround, you could have elisp wrapper that call image magic to create a resized file as temp and display that.

convert -scale 50% girl.jpg girl-s.jpg

you could also call “identify” to get the image dimension first, then some function in emacs to get the emacs window size, so that you can use the proper scale factor to make the image fit to window.

here's a elisp that gets img dimension in pure elisp

(defun get-image-dimensions (img-file-relative-path)
"Returns a image file's width and height as a list."
(let (tmp dimen)
(setq tmp
(create-image (concat default-directory img-file-relative-path)))
(setq dimen (image-size tmp t))
(list (car dimen) (cdr dimen))

probably best just to view it in a dedicated image viewer. You can easily write a elisp so that pressing a button shows the image in a external app. (i suppose this is already in image-mode?)

∑ http://xahlee.org/


No comments:

Post a Comment