Subject: bug#24393: 25.1.50; image-mode ignore the image :scale

From: Eli Zaretskii <[email-masked]>
Date: Fri, 09 Sep 2016 11:06:19 +0300

> From: Tino Calancha <[email-masked]>
> Date: Fri, 9 Sep 2016 03:13:36 +0900 (JST)
> cc: Tino Calancha <[email-masked]>, [email-masked]
> 
> >> emacs -Q IMAGE ; IMAGE is the file name of an image file
> >> M-x: image-transform-fit-to-width
> >> ;; assertion fails.  The image width is bigger than the window width.
> >>
> >> This happens after commit: ad1951db
> >
> > Please show a backtrace from the assertion violation.
> Debugger entered: ((cl-assertion-failed (= (car size) (- (nth 2 (window-inside-pixel-edges)) (nth 0 (window-inside-pixel-edges)))) nil 4299 2514))
>    cl--assertion-failed((= (car size) (- (nth 2 (window-inside-pixel-edges)) (nth 0 (window-inside-pixel-edges)))) nil (4299 2514) nil)
>    image-transform-check-size()
>    image-toggle-display-image()
>    image-transform-fit-to-width()
>    eval((image-transform-fit-to-width) nil)
>    eval-expression((image-transform-fit-to-width) nil)
>    funcall-interactively(eval-expression (image-transform-fit-to-width) 
> nil)
>    call-interactively(eval-expression nil nil)
>    command-execute(eval-expression)

Isn't there something wrong with the logic from the following fragment
of image-toggle-display-image?  The comment certainly seems to have it
backwards, or at least in contradiction to what
image-transform-fit-to-width expects.

	 ;; If we have a `fit-width' or a `fit-height', don't limit
	 ;; the size of the image to the window size.
	 (edges (and (null image-transform-resize)
		     (window-inside-pixel-edges
		      (get-buffer-window (current-buffer)))))

I think 'edges' should be non-nil if image-transform-resize is
non-nil, no?