Subject: Re: bug#33990: 27.0.50; image-transform-fit-to-height/-width violates assert

From: Benjamin Riefenstahl <[email-masked]>
Date: Sun, 06 Jan 2019 10:12:13 +0100

Eli Zaretskii writes:
> Please show the error message and the Lisp backtrace from the error,
> and also the values of the relevant variables.

Values:

  size -> (995 . 1068) ; From image-display-size, i.e. the image dimensions 
  (window-inside-pixel-edges) -> (8 0 933 970)

And yes, the image is actually higher than the window, it can be
scrolled.  The original image is rather small, 75x80, and the
difference, 1068 - 970 -> 98, is about the size of an original pixel
after transformation, so this looks like a rounding problem.  Maybe the
code should adjust by one original pixel when it calculates the target
height in image-transform-properties?

Stacktrace:

  Debugger entered--Lisp error: (cl-assertion-failed ((= (cdr size) (- (nth 3 (window-inside-pixel-edges)) (nth 1 (window-inside-pixel-edges)))) nil 1068 970))
    cl--assertion-failed((= (cdr size) (- (nth 3 (window-inside-pixel-edges)) (nth 1 (window-inside-pixel-edges)))) nil (1068 970) nil)
    (or (= (cdr size) (- (nth 3 (window-inside-pixel-edges)) (nth 1 (window-inside-pixel-edges)))) (cl--assertion-failed '(= (cdr size) (- (nth 3 (window-inside-pixel-edges)) (nth 1 (window-inside-pixel-edges)))) nil (list (cdr size) (- (nth 3 (window-inside-pixel-edges)) (nth 1 (window-inside-pixel-edges)))) (list)))
    (progn (or (= (cdr size) (- (nth 3 (window-inside-pixel-edges)) (nth 1 (window-inside-pixel-edges)))) (cl--assertion-failed '(= (cdr size) (- (nth 3 (window-inside-pixel-edges)) (nth 1 (window-inside-pixel-edges)))) nil (list (cdr size) (- (nth 3 (window-inside-pixel-edges)) (nth 1 (window-inside-pixel-edges)))) (list))) nil)
    (cl-assert (= (cdr size) (- (nth 3 (window-inside-pixel-edges)) (nth 1 (window-inside-pixel-edges)))) t)
    (cond ((eq image-transform-resize 'fit-width) (cl-assert (= (car size) (- (nth 2 (window-inside-pixel-edges)) (nth 0 (window-inside-pixel-edges)))) t)) ((eq image-transform-resize 'fit-height) (cl-assert (= (cdr size) (- (nth 3 (window-inside-pixel-edges)) (nth 1 (window-inside-pixel-edges)))) t)))
    (let ((size (image-display-size (image-get-display-property) t))) (cond ((eq image-transform-resize 'fit-width) (cl-assert (= (car size) (- (nth 2 (window-inside-pixel-edges)) (nth 0 (window-inside-pixel-edges)))) t)) ((eq image-transform-resize 'fit-height) (cl-assert (= (cdr size) (- (nth 3 (window-inside-pixel-edges)) (nth 1 (window-inside-pixel-edges)))) t))))
    (progn (let ((size (image-display-size (image-get-display-property) t))) (cond ((eq image-transform-resize 'fit-width) (cl-assert (= (car size) (- (nth 2 ...) (nth 0 ...))) t)) ((eq image-transform-resize 'fit-height) (cl-assert (= (cdr size) (- (nth 3 ...) (nth 1 ...))) t)))))
    (if (and (not (numberp image-transform-resize)) (boundp 'image-type) (eq image-type 'imagemagick)) (progn (let ((size (image-display-size (image-get-display-property) t))) (cond ((eq image-transform-resize 'fit-width) (cl-assert (= (car size) (- ... ...)) t)) ((eq image-transform-resize 'fit-height) (cl-assert (= (cdr size) (- ... ...)) t))))))
    (when (and (not (numberp image-transform-resize)) (boundp 'image-type) (eq image-type 'imagemagick)) (let ((size (image-display-size (image-get-display-property) t))) (cond ((eq image-transform-resize 'fit-width) (cl-assert (= (car size) (- (nth 2 ...) (nth 0 ...))) t)) ((eq image-transform-resize 'fit-height) (cl-assert (= (cdr size) (- (nth 3 ...) (nth 1 ...))) t)))))
    image-transform-check-size()
    image-toggle-display-image()
    image-mode()
    set-auto-mode-0(image-mode nil)
    set-auto-mode()
    normal-mode(t)
    after-find-file(nil t)
    find-file-noselect-1(#<buffer att-fin-199.03.14.pbm> "~/Projects/Mandaic-Font/src/199/att-fin-199.03.14...." nil nil "~/Projects/Mandaic-Font/src/199/att-fin-199.03.14...." (17829146 66305))
    find-file-noselect("/home/benny/Projects/Mandaic-Font/src/199/att-fin-..." nil nil nil)
    find-file("/home/benny/Projects/Mandaic-Font/src/199/att-fin-...")
    dired-find-file()
    funcall-interactively(dired-find-file)
    call-interactively(dired-find-file nil nil)
    command-execute(dired-find-file)
    recursive-edit()
    debug(error (cl-assertion-failed ((= (cdr size) (- (nth 3 (window-inside-pixel-edges)) (nth 1 (window-inside-pixel-edges)))) nil 1067 970)))
    cl--assertion-failed((= (cdr size) (- (nth 3 (window-inside-pixel-edges)) (nth 1 (window-inside-pixel-edges)))) nil (1067 970) nil)
    image-transform-check-size()
    image-toggle-display-image()
    image-transform-fit-to-height()
    funcall-interactively(image-transform-fit-to-height)
    call-interactively(image-transform-fit-to-height nil nil)
    command-execute(image-transform-fit-to-height)