[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Images :scale and :width/:height relation
From: |
Alan Third |
Subject: |
Re: Images :scale and :width/:height relation |
Date: |
Fri, 1 Sep 2023 21:57:38 +0100 |
On Fri, Sep 01, 2023 at 12:46:11PM +0200, Manuel Giraud via Emacs development
discussions. wrote:
> Hi,
>
> For the need of bug#65581, I'd like to have access to the current scale
> of an image. But it seems that this one does not always reflect
> reality. For instance, you can have a image with an original width of
> 500 scaled down to a width of 100 (by mean of the :width keyword) and
> its :scale keyword will still be 1.
>
> In "(elisp) Image Descriptors", it is said that:
>
> If both ‘:scale’ and ‘:height’/‘:width’ are specified, the
> height/width will be adjusted by the specified scaling factor.
>
> But it does not seems to work the other way around.
I think you've maybe misunderstood. If you set :width 100, and :scale
2, then the actual image will have a width of 200. The image spec will
still say :width 100 :scale 2.
> Wouldn't it be a good thing if 'create-image' return a
> « normalized » image spec where the :width, :height and :scale are
> filled and kept in sync?
It would probably be nice, but it's not that easy as you can't work
out the scale, given a desired width or height, without loading the
image first to get the real width, and Emacs only loads the image at
display time.
IIRC the likes of eww will actively load an image and then get the
size and set the scale accordingly. Perhaps that sort of behaviour
should be made available generally.
--
Alan Third