GNU bug report logs - #74725
31.0.50; image-scaling-factor is ignored by create-image

Previous Next

Package: emacs;

Reported by: David Ponce <da_vid <at> orange.fr>

Date: Sat, 7 Dec 2024 12:15:02 UTC

Severity: normal

Found in version 31.0.50

Done: Alan Third <alan <at> idiocy.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: David Ponce <da_vid <at> orange.fr>
Subject: bug#74725: closed (Re: bug#74725: 31.0.50; image-scaling-factor
 is ignored by create-image)
Date: Sat, 28 Dec 2024 12:39:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#74725: 31.0.50; image-scaling-factor is ignored by create-image

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 74725 <at> debbugs.gnu.org.

-- 
74725: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=74725
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Alan Third <alan <at> idiocy.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: luangruo <at> yahoo.com, 74725-done <at> debbugs.gnu.org, da_vid <at> orange.fr
Subject: Re: bug#74725: 31.0.50; image-scaling-factor is ignored by
 create-image
Date: Sat, 28 Dec 2024 12:37:52 +0000
On Sat, Dec 28, 2024 at 02:26:47PM +0200, Eli Zaretskii wrote:
> > Date: Fri, 27 Dec 2024 12:11:33 +0000
> > From: Alan Third <alan <at> idiocy.org>
> > Cc: Po Lu <luangruo <at> yahoo.com>, 74725 <at> debbugs.gnu.org, da_vid <at> orange.fr
> > 
> > > Alan, could you please prepare a patch (for the master branch) that
> > > records the scaling factor in the image cache and rejects a cache hit
> > > with a different scaling factor?
> > 
> > Hi Eli, patch attached.
> 
> Thanks, LGTM.
> 
> > I named a new function image_compute_scale because most of the other
> > functions in that file start image_, however I wasn't sure if I should
> > name it compute_image_scale to mirror compute_image_size. Let me know
> > if you think I should change it.
> 
> Static functions can have any names we see fit, so feel free to rename
> if you think compute_image_scale would be better.
> 
> Feel free to install on master, when you are satisfied with the code.

Done. Thanks.
-- 
Alan Third

[Message part 3 (message/rfc822, inline)]
From: David Ponce <da_vid <at> orange.fr>
To: bug-gnu-emacs <at> gnu.org
Subject: 31.0.50; image-scaling-factor is ignored by create-image
Date: Sat, 7 Dec 2024 13:13:58 +0100
Hello,

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)


Thanks!


In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.43, cairo version 1.18.0) of 2024-12-02
Repository revision: 8cd4ab7abde87ac04e05442196b4646ab46df9a7
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12014000
System Description: Fedora Linux 40 (KDE Plasma)

Configured using:
 'configure --with-native-compilation=no
 PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Important settings:
  value of $LC_TIME: fr_FR.utf8
  value of $LANG: fr_FR.UTF-8
  locale-coding-system: utf-8-unix




This bug report was last modified 146 days ago.

Previous Next


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