Function: image-compute-scaling-factor
image-compute-scaling-factor is a byte-compiled function defined in
image.el.gz.
Signature
(image-compute-scaling-factor &optional SCALING)
Documentation
Compute the scaling factor based on SCALING.
If a number, use that. If it's auto, compute the factor.
If nil, use the image-scaling-factor variable.
This function is provided for the benefit of Lisp code that must compute this factor; it does not affect Emacs's scaling of images.
Source Code
;; Defined in /usr/src/emacs/lisp/image.el.gz
(defun image-compute-scaling-factor (&optional scaling)
"Compute the scaling factor based on SCALING.
If a number, use that. If it's `auto', compute the factor.
If nil, use the `image-scaling-factor' variable.
This function is provided for the benefit of Lisp code that
must compute this factor; it does not affect Emacs's scaling
of images."
(unless scaling
(setq scaling image-scaling-factor))
(cond
((numberp scaling) scaling)
((eq scaling 'auto)
(let ((width (/ (float (window-width nil t)) (window-width))))
;; If we assume that a typical character is 10 pixels in width,
;; then we should scale all images according to how wide they
;; are. But don't scale images down.
(if (< width 10)
1
(/ (float width) 10))))
(t
(error "Invalid scaling factor %s" scaling))))