In almost all cases, I want to see JPEGs such as photos scaled to the current buffer size. This is the default with image-mode
. However, for PNG files, primarity screenshots, I want to view them without scaling by default.
How do I best assign scaling behavior based on file type?
By the way, image-mode
is not a requirement. I am fine with switching to something else.
Update
Based on Jordon Biondo's answer, I am now using the following setup:
(defun my-image-mode-hook ()
(when (and (display-images-p) (eq image-type 'imagemagick))
(let ((extension (downcase (file-name-extension
(buffer-file-name)))))
(when (string-match-p "^\\(png\\|gif\\|bmp\\)$" extension)
(image-transform-set-scale 1)
(setq image-transform-resize nil)))))
(add-hook 'image-mode-hook 'my-image-mode-hook)
This never scales images of type PNG, GIF, or BMP. All other images are scaled, as per default, to fit into the buffer. To prevent additional scaling based on selected font size, I have customized:
'(image-scaling-factor 1)