GNU bug report logs - #24393
25.1.50; image-mode ignore the image :scale

Previous Next

Package: emacs;

Reported by: Tino Calancha <tino.calancha <at> gmail.com>

Date: Thu, 8 Sep 2016 12:15:01 UTC

Severity: normal

Tags: moreinfo

Found in version 25.1.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 24393 in the body.
You can then email your comments to 24393 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#24393; Package emacs. (Thu, 08 Sep 2016 12:15:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tino Calancha <tino.calancha <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 08 Sep 2016 12:15:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.1.50; image-mode ignore the image :scale
Date: Thu, 8 Sep 2016 21:14:26 +0900 (JST)
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

In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.21.5)
 of 2016-09-07
Repository revision: ba5d32398ba42fcf14ad5242d95c68133981744f





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24393; Package emacs. (Thu, 08 Sep 2016 17:17:01 GMT) Full text and rfc822 format available.

Message #8 received at 24393 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 24393 <at> debbugs.gnu.org
Subject: Re: bug#24393: 25.1.50; image-mode ignore the image :scale
Date: Thu, 08 Sep 2016 20:15:39 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Thu, 8 Sep 2016 21:14:26 +0900 (JST)
> 
> 
> 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.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24393; Package emacs. (Thu, 08 Sep 2016 18:14:02 GMT) Full text and rfc822 format available.

Message #11 received at 24393 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 24393 <at> debbugs.gnu.org, Tino Calancha <tino.calancha <at> gmail.com>
Subject: Re: bug#24393: 25.1.50; image-mode ignore the image :scale
Date: Fri, 9 Sep 2016 03:13:36 +0900 (JST)

On Thu, 8 Sep 2016, Eli Zaretskii wrote:

>> From: Tino Calancha <tino.calancha <at> gmail.com>
>> Date: Thu, 8 Sep 2016 21:14:26 +0900 (JST)
>>
>>
>> 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)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24393; Package emacs. (Fri, 09 Sep 2016 08:07:01 GMT) Full text and rfc822 format available.

Message #14 received at 24393 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 24393 <at> debbugs.gnu.org
Subject: Re: bug#24393: 25.1.50; image-mode ignore the image :scale
Date: Fri, 09 Sep 2016 11:06:19 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Fri, 9 Sep 2016 03:13:36 +0900 (JST)
> cc: Tino Calancha <tino.calancha <at> gmail.com>, 24393 <at> debbugs.gnu.org
> 
> >> 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?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24393; Package emacs. (Fri, 09 Sep 2016 10:24:01 GMT) Full text and rfc822 format available.

Message #17 received at 24393 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 24393 <at> debbugs.gnu.org, Tino Calancha <tino.calancha <at> gmail.com>
Subject: Re: bug#24393: 25.1.50; image-mode ignore the image :scale
Date: Fri, 9 Sep 2016 19:23:02 +0900 (JST)

On Fri, 9 Sep 2016, Eli Zaretskii wrote:

> 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?
I think is OK.  Maybe i would adjust the comment a bit, because 
`image-transform-resize' can also be a number (set by 
`image-transform-set-scale'): i would say:
;; If `image-transform-resize' is non-nil, don't limit
;; the size of the image to the window size.

I think the logic is as follows:
The proportion width/height is an invariant of this transformation.
If you call `image-transform-fit-to-width', your image width will occupy 
all the window width.  Then, the height is increased in the same 
proportion as the width, so the final image height may be longer than
the window height.  That's OK.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24393; Package emacs. (Fri, 09 Sep 2016 13:17:02 GMT) Full text and rfc822 format available.

Message #20 received at 24393 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 24393 <at> debbugs.gnu.org
Subject: Re: bug#24393: 25.1.50; image-mode ignore the image :scale
Date: Fri, 09 Sep 2016 16:15:58 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Fri, 9 Sep 2016 19:23:02 +0900 (JST)
> cc: Tino Calancha <tino.calancha <at> gmail.com>, 24393 <at> debbugs.gnu.org
> 
> > 	 ;; 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?
> I think is OK.  Maybe i would adjust the comment a bit, because 
> `image-transform-resize' can also be a number (set by 
> `image-transform-set-scale'): i would say:
> ;; If `image-transform-resize' is non-nil, don't limit
> ;; the size of the image to the window size.
> 
> I think the logic is as follows:
> The proportion width/height is an invariant of this transformation.
> If you call `image-transform-fit-to-width', your image width will occupy 
> all the window width.  Then, the height is increased in the same 
> proportion as the width, so the final image height may be longer than
> the window height.  That's OK.

When image-transform-fit-to-width sets image-transform-resize to the
symbol 'fit-width', image-toggle-display-image will not pass any
dimensions to create-image.  So how will the image be resized at all
in this case?  What am I missing?

And how do you explain the assertion violation in this case, anyway?
What are the window dimensions in pixels?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24393; Package emacs. (Fri, 09 Sep 2016 13:52:02 GMT) Full text and rfc822 format available.

Message #23 received at 24393 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 24393 <at> debbugs.gnu.org, Tino Calancha <tino.calancha <at> gmail.com>
Subject: Re: bug#24393: 25.1.50; image-mode ignore the image :scale
Date: Fri, 9 Sep 2016 22:51:04 +0900 (JST)

On Fri, 9 Sep 2016, Eli Zaretskii wrote:

>> From: Tino Calancha <tino.calancha <at> gmail.com>
>> Date: Fri, 9 Sep 2016 19:23:02 +0900 (JST)
>> cc: Tino Calancha <tino.calancha <at> gmail.com>, 24393 <at> debbugs.gnu.org
>>
>>> 	 ;; 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?
>> I think is OK.  Maybe i would adjust the comment a bit, because
>> `image-transform-resize' can also be a number (set by
>> `image-transform-set-scale'): i would say:
>> ;; If `image-transform-resize' is non-nil, don't limit
>> ;; the size of the image to the window size.
>>
>> I think the logic is as follows:
>> The proportion width/height is an invariant of this transformation.
>> If you call `image-transform-fit-to-width', your image width will occupy
>> all the window width.  Then, the height is increased in the same
>> proportion as the width, so the final image height may be longer than
>> the window height.  That's OK.
>
> When image-transform-fit-to-width sets image-transform-resize to the
> symbol 'fit-width', image-toggle-display-image will not pass any
> dimensions to create-image.  So how will the image be resized at all
> in this case?  What am I missing?
It is done inside `image-toggle-display-image'.  Maybe the word 'toggle'
inside this function is misleading: indeed it looks more than a toggle.
This 'toggle' calls `image-transform-properties' which calculate the
resize for 'fit-width/'fit-height cases.
> And how do you explain the assertion violation in this case, anyway?
> What are the window dimensions in pixels?
The same 'toggle' calls `image-transform-check-size' to check 
the sizes (do the cl-asserts).

I guess, the origin of the problem is that these functions,
`image-transform-properties' and `image-transform-check-size',
don't use the image scale. After the commit mentioned in my original 
report, the scale of an image matters.  We need somehow to teach 
`image-mode' to use :scale to fix this bug.
We could fix this file amending those functions.  I tried before and
i didn't like this approach.

I also suggested in
https://lists.gnu.org/archive/html/emacs-devel/2016-09/msg00159.html
that if image-mode.el uses more the API in image.el (maybe extending 
the API a bit ), then this bug could get fix easily; currently both
files define resizes and rotations; for me it has much sense that,
if the API already provide those functionalities, then image-mode.el
just use them: one source of truth, easier to maintain.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24393; Package emacs. (Thu, 26 Sep 2019 16:00:02 GMT) Full text and rfc822 format available.

Message #26 received at 24393 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 24393 <at> debbugs.gnu.org
Subject: Re: bug#24393: 25.1.50; image-mode ignore the image :scale
Date: Thu, 26 Sep 2019 17:59:22 +0200
Tino Calancha <tino.calancha <at> gmail.com> writes:

> 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.

I'm unable to reproduce this bug in Emacs 27.  Are you still seeing
this?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 26 Sep 2019 16:00:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24393; Package emacs. (Thu, 26 Sep 2019 17:43:02 GMT) Full text and rfc822 format available.

Message #31 received at 24393 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 24393 <at> debbugs.gnu.org
Subject: Re: bug#24393: 25.1.50; image-mode ignore the image :scale
Date: Thu, 26 Sep 2019 19:42:38 +0200 (CEST)

On Thu, 26 Sep 2019, Lars Ingebrigtsen wrote:

> Tino Calancha <tino.calancha <at> gmail.com> writes:
>
>> 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.
>
> I'm unable to reproduce this bug in Emacs 27.  Are you still seeing
> this?

No, I don't see this anymore; and I am using 
`image-transform-fit-to-width' `image-transform-fit-to-height' quite 
often.  It seems fixed.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24393; Package emacs. (Thu, 26 Sep 2019 17:50:02 GMT) Full text and rfc822 format available.

Message #34 received at 24393 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 24393 <at> debbugs.gnu.org
Subject: Re: bug#24393: 25.1.50; image-mode ignore the image :scale
Date: Thu, 26 Sep 2019 19:49:24 +0200
Tino Calancha <tino.calancha <at> gmail.com> writes:

> No, I don't see this anymore; and I am using
> `image-transform-fit-to-width' `image-transform-fit-to-height' quite 
> often.  It seems fixed.

Thanks; closing.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 24393 <at> debbugs.gnu.org and Tino Calancha <tino.calancha <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 26 Sep 2019 17:50:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 25 Oct 2019 11:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 55 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.