unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Images :scale and :width/:height relation
@ 2023-09-01  9:54 Manuel Giraud
  0 siblings, 0 replies; 5+ messages in thread
From: Manuel Giraud @ 2023-09-01  9:54 UTC (permalink / raw)
  To: emacs-devel

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.  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?

If yes, I think we should have answers for the following questions:

   - Does :scale have priority over :width or :height? Or the opposite?
   
   - What would be the :scale of an image that does not preserve aspect
     ratio?
-- 
Manuel Giraud



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Images :scale and :width/:height relation
@ 2023-09-01 10:46 Manuel Giraud via Emacs development discussions.
  2023-09-01 20:57 ` Alan Third
  0 siblings, 1 reply; 5+ messages in thread
From: Manuel Giraud via Emacs development discussions. @ 2023-09-01 10:46 UTC (permalink / raw)
  To: emacs-devel

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.  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?

If yes, I think we should have answers for the following questions:

   - Does :scale have priority over :width or :height? Or the opposite?
   
   - What would be the :scale of an image that does not preserve aspect
     ratio?
-- 
Manuel Giraud



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Images :scale and :width/:height relation
  2023-09-01 10:46 Images :scale and :width/:height relation Manuel Giraud via Emacs development discussions.
@ 2023-09-01 20:57 ` Alan Third
  2023-09-03 13:37   ` Manuel Giraud via Emacs development discussions.
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Third @ 2023-09-01 20:57 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: emacs-devel

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Images :scale and :width/:height relation
  2023-09-01 20:57 ` Alan Third
@ 2023-09-03 13:37   ` Manuel Giraud via Emacs development discussions.
  2023-09-03 16:40     ` Alan Third
  0 siblings, 1 reply; 5+ messages in thread
From: Manuel Giraud via Emacs development discussions. @ 2023-09-03 13:37 UTC (permalink / raw)
  To: Alan Third; +Cc: emacs-devel

Alan Third <alan@idiocy.org> writes:

> 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.

Ok.  So with both a :width and a :scale, each does its scaling.  From
the info, I thought that a :scale set would then modify :width
accordingly.

>> 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.

Hum, I see.

> 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.

I should have a look their then.  But Emacs does not have a way of
asking "what are the dimensions of this image" without loading it into
its cache?
-- 
Manuel Giraud



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Images :scale and :width/:height relation
  2023-09-03 13:37   ` Manuel Giraud via Emacs development discussions.
@ 2023-09-03 16:40     ` Alan Third
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Third @ 2023-09-03 16:40 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: emacs-devel

On Sun, Sep 03, 2023 at 03:37:11PM +0200, Manuel Giraud wrote:
> > 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.
> 
> I should have a look their then.  But Emacs does not have a way of
> asking "what are the dimensions of this image" without loading it into
> its cache?

No, afaik the only way to get an image's native dimensions is to load
it with no scale or width/height and then check the resulting image.
-- 
Alan Third



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-09-03 16:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-01 10:46 Images :scale and :width/:height relation Manuel Giraud via Emacs development discussions.
2023-09-01 20:57 ` Alan Third
2023-09-03 13:37   ` Manuel Giraud via Emacs development discussions.
2023-09-03 16:40     ` Alan Third
  -- strict thread matches above, loose matches on Subject: below --
2023-09-01  9:54 Manuel Giraud

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).