all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: David Ponce <da_vid@orange.fr>, Po Lu <luangruo@yahoo.com>
Cc: 74725@debbugs.gnu.org, alan@idiocy.org
Subject: bug#74725: 31.0.50; image-scaling-factor is ignored by create-image
Date: Sat, 07 Dec 2024 18:45:37 +0200	[thread overview]
Message-ID: <86y10rh26m.fsf@gnu.org> (raw)
In-Reply-To: <2793f551-8715-4679-8f52-b4673dd6802d@orange.fr> (message from David Ponce on Sat, 7 Dec 2024 17:27:13 +0100)

> Date: Sat, 7 Dec 2024 17:27:13 +0100
> From: David Ponce <da_vid@orange.fr>
> 
> On 2024-12-07 16:49, Alan Third wrote:
> > On Sat, Dec 07, 2024 at 04:49:41PM +0200, Eli Zaretskii wrote:
> >>> Date: Sat, 7 Dec 2024 13:13:58 +0100
> >>> From:  David Ponce via "Bug reports for GNU Emacs,
> >>>   the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> >>>
> >>> While working with images, I found what seems an issue to me with
> >>> `create-image' which unconditionally set the :scale image property to
> >>> 'default' when not specified, ignoring the value of the option
> >>> `image-scaling-factor'.
> >>>
> >>> Here is an illustration:
> >>>
> >>> (let ((image-scaling-factor 1.0))
> >>>      (image-size
> >>>       (find-image '((:file "icons/hicolor/scalable/apps/emacs.svg")))
> >>>       t))
> >>> => (63 . 63)
> >>>
> >>> (let ((image-scaling-factor 2.0))
> >>>      (image-size
> >>>       (find-image '((:file "icons/hicolor/scalable/apps/emacs.svg")))
> >>>       t))
> >>> => (63 . 63)
> >>>
> >>> (image-size
> >>>     (find-image '((:file "icons/hicolor/scalable/apps/emacs.svg" :scale 1)))
> >>>     t)
> >>> => (48 . 48)
> >>>
> >>> (image-size
> >>>     (find-image '((:file "icons/hicolor/scalable/apps/emacs.svg" :scale 2)))
> >>>     t)
> >>> => (96 . 96)
> >>>
> >>> You can replace `image-size' with `insert-image' and observe the same.
> >>>
> >>> Here is a simple patch which fix the issue for me:
> >>>
> >>> diff --git a/lisp/image.el b/lisp/image.el
> >>> index ce97eeb3ca1..2c1e865c336 100644
> >>> --- a/lisp/image.el
> >>> +++ b/lisp/image.el
> >>> @@ -536,7 +536,9 @@ create-image
> >>>                             file-or-data)
> >>>                       (and (not (plist-get props :scale))
> >>>                            ;; Add default scaling.
> >>> -                        (list :scale 'default))
> >>> +                        (list :scale (if (numberp image-scaling-factor)
> >>> +                                         image-scaling-factor
> >>> +                                       'default)))
> >>>    	           props)))
> >>>          ;; Add default smoothing.
> >>>          (unless (plist-member props :transform-smoothing)
> >>
> >> AFAIU, this is supposed to be taken care of in image.c.
> >>
> >> Alan, any ideas why this doesn't seem to work?
> > 
> > It's because the image spec doesn't change so the image is pulled from
> > the cache each time.
> > 
> > Flushing the image between calls to image-size fixes it:
> > 
> >      (image-flush (find-image '((:file "icons/hicolor/scalable/apps/emacs.svg"))))
> > 
> > I'm not sure what the solution is here. My feeling is that
> > image-scaling-factor isn't intended as something you set for each
> > image as you load it, it's a set-and-forget setting, so perhaps we
> > just need to document that in order for it to take effect the image
> > cache needs to be flushed.
> > 
> > Alternatively we make the image cache aware of it.
> > 
> > Perhaps we can flush the cache automatically when it changes? That
> > might give unexpected results too.
> 
> This is exactly what I also observe.
> It seems due to this change:
> 
> author	Po Lu <luangruo@yahoo.com>	2024-06-03 16:34:51 +0800
> committer	Po Lu <luangruo@yahoo.com>	2024-06-03 16:36:29 +0800
> commit	56376585134d627f96c71b7b063ec51548d3ad3f (patch)
> 
> Which replaced
> 
> -                        (list :scale
> -                              (image-compute-scaling-factor
> -                               image-scaling-factor)))
> 
> By this
> 
> +                        (list :scale 'default))
> 
> In create-image.
> 
> With the side effect that the image spec don't change when the scaling
> factor changes, so the same cached image in always used.

Po Lu, what were the reasons for that particular part of the commit?





  reply	other threads:[~2024-12-07 16:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-07 12:13 bug#74725: 31.0.50; image-scaling-factor is ignored by create-image David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-07 12:41 ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-07 14:49 ` Eli Zaretskii
2024-12-07 15:49   ` Alan Third
2024-12-07 16:21     ` Eli Zaretskii
2024-12-07 16:32       ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-07 16:27     ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-07 16:45       ` Eli Zaretskii [this message]
2024-12-08  0:01         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-08  6:03           ` Eli Zaretskii
2024-12-08  8:03             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-08 12:15               ` Eli Zaretskii
2024-12-21  9:14                 ` Eli Zaretskii
2024-12-22  0:26                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86y10rh26m.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=74725@debbugs.gnu.org \
    --cc=alan@idiocy.org \
    --cc=da_vid@orange.fr \
    --cc=luangruo@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.