From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: David Ponce 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: Sat, 7 Dec 2024 17:32:20 +0100 Message-ID: <35011415-9a37-4825-93d7-133948ceccbf@orange.fr> References: <2304cad6-884f-4528-a85e-ab9c06b80016@orange.fr> <868qsrim4a.fsf@gnu.org> <861pyjihve.fsf@gnu.org> Reply-To: David Ponce Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25355"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: 74725@debbugs.gnu.org To: Eli Zaretskii , Alan Third Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 07 17:33:24 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 1tJxkC-0006Nj-6I for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 07 Dec 2024 17:33:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJxjs-0003M6-QS; Sat, 07 Dec 2024 11:33:04 -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 1tJxjr-0003Lt-QN for bug-gnu-emacs@gnu.org; Sat, 07 Dec 2024 11:33:03 -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 1tJxjr-0007eX-FE for bug-gnu-emacs@gnu.org; Sat, 07 Dec 2024 11:33:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=In-Reply-To:From:References:MIME-Version:Date:To:Subject; bh=JUmihdT1EzzILTO/A2gtc/OvhUP1R0X/EKVqGzvW+WY=; b=bQnQYqfNt555jlhHbezw977TwdbzEQ7ZZVI28DXpirCqyN6k+euVcivLBhQAIErs/5Xom/coi9cYh9DHpAaz+QSH8pS0BKeaakYYs4giiyEqwe9KQN9P2c5MoZ7k5mgzRWjLBcO9dfWj75qUOvAY0JKmkGjF4OGdkIuhX7QQlF/wtFCyR8Mid1DkyrB0I+rawc+iQwVCRD9RJGYx2INDpOPURnE9HlNkh6eHeI72T515/L4dlKGfRy/+tcOcQswhQ6p/LKKSbMcruDQvN+GOgFQ5yM9P5/WIEVsoziFUVRk+eGaHr28KamOUcN43vXbuEKI1sQE5ehAIvnbB0XUOvw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tJxjq-0006OW-9G for bug-gnu-emacs@gnu.org; Sat, 07 Dec 2024 11:33:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: David Ponce Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 07 Dec 2024 16:33: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.173358914624520 (code B ref 74725); Sat, 07 Dec 2024 16:33:02 +0000 Original-Received: (at 74725) by debbugs.gnu.org; 7 Dec 2024 16:32:26 +0000 Original-Received: from localhost ([127.0.0.1]:48296 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJxjG-0006NP-7e for submit@debbugs.gnu.org; Sat, 07 Dec 2024 11:32:26 -0500 Original-Received: from smtp-22.smtpout.orange.fr ([80.12.242.22]:47185 helo=smtp.smtpout.orange.fr) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJxjD-0006NG-U8 for 74725@debbugs.gnu.org; Sat, 07 Dec 2024 11:32:24 -0500 Original-Received: from [192.168.1.21] ([90.112.40.65]) by smtp.orange.fr with ESMTPA id JxjAth4tA60jWJxjBtiotE; Sat, 07 Dec 2024 17:32:23 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1733589143; bh=JUmihdT1EzzILTO/A2gtc/OvhUP1R0X/EKVqGzvW+WY=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=C3IFHSvmc5JCVDpIuNg2Uag5lusERntE4XoKRZA0eDjHXbu0sdNBIhAAKkgEWTqCi qnV8Cf6I7OMqkLVfgPVyFZrdfCY59QyMD2NvAuYXrU3x6Dy5OHrKJrLQ7551P2zOty CsmOTZnjHga7uwNA0U6yMr0Sr0OX397UjCq8AoUdmYP1RRlA880SEPmNGK5iJFF+Xb GL+a4hTKmwLez7kIhXIt7Nsbl3Cl1F45+ZRfe/F2BqpEfCduU1Hs7/OnyOEbLk+3VC ta9sqsm6MNdElk4sc3vtL7bhma5QuQyPPfAbuR1Q/9gaMcK+0Li0SZ4VMDzAo4Glbz g5+BWlf7umpUA== X-ME-Helo: [192.168.1.21] X-ME-Auth: ZGFfdmlkQHdhbmFkb28uZnI= X-ME-Date: Sat, 07 Dec 2024 17:32:23 +0100 X-ME-IP: 90.112.40.65 Content-Language: fr, en-US In-Reply-To: <861pyjihve.fsf@gnu.org> 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:296580 Archived-At: On 2024-12-07 17:21, Eli Zaretskii wrote: >> Date: Sat, 7 Dec 2024 15:49:47 +0000 >> From: Alan Third >> Cc: David Ponce , 74725@debbugs.gnu.org >> >> 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. > > I think recording the scale in the cache, and rejecting the cached > image if the scale doesn't match, will cause the least surprise. But > I'm open to other opinions and suggestions. > Seems like a good idea.