From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74725: 31.0.50; image-scaling-factor is ignored by create-image Date: Sun, 08 Dec 2024 08:01:39 +0800 Message-ID: <87plm3ghzw.fsf@yahoo.com> References: <2304cad6-884f-4528-a85e-ab9c06b80016@orange.fr> <868qsrim4a.fsf@gnu.org> <2793f551-8715-4679-8f52-b4673dd6802d@orange.fr> <86y10rh26m.fsf@gnu.org> Reply-To: Po Lu Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4220"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 74725@debbugs.gnu.org, David Ponce , alan@idiocy.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 08 01:02:23 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tK4kg-0000x1-2d for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 08 Dec 2024 01:02:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tK4kP-0004Dm-TQ; Sat, 07 Dec 2024 19:02:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tK4kO-0004DJ-4r for bug-gnu-emacs@gnu.org; Sat, 07 Dec 2024 19:02:04 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tK4kM-0000Jd-FZ for bug-gnu-emacs@gnu.org; Sat, 07 Dec 2024 19:02:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=g6pXb9+D+WpXq58KjW8aTn8IZmKQJFB/Y/MsBUK9JNs=; b=QtYasKI1z8G0gqq5V2Zns/qiyxWIiBjq4mzLeX0onaKEzfeDrG/dV+7AdHMFPoMXn0mZaQxmQjucO05S8C6LCpoz96RdKmfNYV4P/OwcqW/N3a5rOyl9GXyUsfwmyYo4+5SE0gP0Dtp3dzhsAWJ7o8TD5tdhEoBB0Ui9tfP3m0aU4po0Okd9yHpDgnfmcxNLbqzxDLa/vV+COjttGC0sfVNpwuVGCSyFIzFtuJmuzMFIrKakKLdbqlMb9r3MOkHGZXOwBqqDEu0a4C2AzQliBGoJcEQK64GzhLPbVOXOfEngK15U4k0/OSXaV65m/rygT04NhHO/Dq2lXT7o1/U9bQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tK4kM-0003RP-9R for bug-gnu-emacs@gnu.org; Sat, 07 Dec 2024 19:02:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 Dec 2024 00:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74725 X-GNU-PR-Package: emacs Original-Received: via spool by 74725-submit@debbugs.gnu.org id=B74725.173361611813216 (code B ref 74725); Sun, 08 Dec 2024 00:02:02 +0000 Original-Received: (at 74725) by debbugs.gnu.org; 8 Dec 2024 00:01:58 +0000 Original-Received: from localhost ([127.0.0.1]:48979 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tK4kH-0003R2-Bc for submit@debbugs.gnu.org; Sat, 07 Dec 2024 19:01:58 -0500 Original-Received: from sonic305-22.consmr.mail.ne1.yahoo.com ([66.163.185.148]:40019) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tK4kF-0003Qm-GD for 74725@debbugs.gnu.org; Sat, 07 Dec 2024 19:01:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1733616110; bh=g6pXb9+D+WpXq58KjW8aTn8IZmKQJFB/Y/MsBUK9JNs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=F5kjYzojSeCVoN6VL43PUZfTUSKpRn04PwpuqI0juL4X/5t3d6JU45q3ACwd9sTBFQ4PobbeRT2fRAt600XAd+XFfZnsE0ignwMUqPM7fU7MmUzBzacVZbpMwW36iOBQj+S32uapHj8+hquDU0Q2STIBSk44iOor33jgm7J21L4v0J2JgJt7ucHymsfeuF9vpl2Ch4kMjke5JHSMIOngvhMXu72sn/k3PO0OOxmyUot3Dg66P23OaRrVOrsytoS64Oyh55MLmOPKcJ1kq+WD0aj5wLBZ0jZnRl3Fkzgbnsgtld6rLZGgYV2SCbneFGUWHOIX1O7Lf11TMWqq4oXoWQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1733616110; bh=UwNsXwSGZBFND5Qaz6/dBGsRiVgWxR/+wFMK8Z0jyZs=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=LFjTbCs+Us96dAHJjjtxj+SpPf8ZOzEmV9PVc9FUmh243rm6/GFZi8MakhpT0u79Lv38kAGpyL1kPi6QkxxRisBwbeoA78LueUfXFeL8HNMTGZs5ljiAI+/wWn2/BdzC9vcKVtxd6fP8GYzs4cw7pp7uVe7JlcX71aEPKlrj3urznxO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07ede4cc-f632-4367-b23c-3b654f70bdd6 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.ne1.yahoo.com with HTTP; Sun, 8 Dec 2024 00:01:50 +0000 Original-Received: by hermes--production-sg3-5b7954b588-bfzf8 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID fd8bb382651edc6e7f92ce987d1d4030; Sun, 08 Dec 2024 00:01:45 +0000 (UTC) In-Reply-To: <86y10rh26m.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 07 Dec 2024 18:45:37 +0200") X-Mailer: WebService/1.1.23040 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:296605 Archived-At: Eli Zaretskii writes: >> Date: Sat, 7 Dec 2024 17:27:13 +0100 >> From: David Ponce >> >> 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" >> >>> >> >>> 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 2024-06-03 16:34:51 +0800 >> committer Po Lu 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? The scale applied by image-scaling-factor is liable to differ by display, and computing the default scale in Lisp would result in images being displayed with an incorrect scale in the presence of multiple displays. Image caches must be flushed when image-scaling-factor is modified, unless it is set to `auto' and a display's scale changes, because image.c has no means of detecting variable modifications and so only the latter event can be automatically detected.