Subject: bug#58101: 28.2; image-size nonsensical

From: Thomas Hühn <[email-masked]>
Date: Tue, 27 Sep 2022 11:00:22 +0200

Hi,

first of all, I think this bug could be merged with #52931, I found that 
only afterwards.

On 27.09.2022 08:05, Eli Zaretskii wrote:
>> Date: Mon, 26 Sep 2022 20:41:45 +0200
>> From: Thomas Hühn <[email-masked]>
>>
>> * Download image https://imgs.xkcd.com/comics/two_key_system_2x.png to
>>     disk
>>
>> * Run (create-image "two_key_system_2x.png") --> (image :type png :file
>>     "two_key_system_2x.png" :scale 1.2038461538461538 :transform-smoothing
>>     t)
>>
>> * Run (image-size (create-image "two_key_system_2x.png") :pixels) -->
>>     (30 . 30)
>>
>> Expected result: (1291 . 632)
> 
> I cannot reproduce this here.  I get the expected result.  I also get

Now it seems like it's an intermittent problem.

Until yesterday (for several weaks where I've tried it every now and 
then) it resulted in what I wrote in this bug.

Then I found #52931 and tried Markus' lines.

In my opinion,

(image-size (create-image "two_key_system_2x.png") :pixels)

and

(let ((img (create-image "two_key_system_2x.png")))
   (image-size img t))

should give the same result, but it didn't! Markus' line gave 1554 . 
760, mine gave 30 . 30.

Later yesterday evening both gave 1554 . 760.

After some googling I found image-scaling-factor, and after setting that 
to 1, I always get the expected 1291 . 632 now.

(By the way, I think image-size should ignore that variable – I'm not 
displaying the image anywhere, so any display scaling shouldn't 
interfere – my use case would be inserting width and height attributes 
in HTML where I certainly want the original image dimensions)

> this result from create-image:
> 
>   (image :type png :file "two_key_system_2x.png" :scale 1 :transform-smoothing t)

With emacs -Q:

(image :type png :file "two_key_system_2x.png" :scale 1.2 
:transform-smoothing t)

That scaling factor is different now. I'll continue with emacs -Q from 
now on.

> Is this in "emacs -Q"?  If so, what version of libpng do you have

mingw64/mingw-w64-x86_64-libpng 1.6.38-1 [installed]

> installed there?  And what happens if you start Emacs like this:
> 
>    emacs -Q --eval "(setq w32-use-native-image-API t)"

(image-size (create-image "two_key_system_2x.png") :pixels)
--> (1549 . 758)

(let ((img (create-image "two_key_system_2x.png")))
   (image-size img t))
--> (1549 . 758)

Have a nice day!
Thomas
-- 
Wunderschön illustrierte Kinderbücher:
https://www.schoene-kinderbuecher.de
Weblog:
https://www.thomas-huehn.de