ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] How to get an image to fill the maximum available space?
       [not found] <702755847.2028514.1711764942052.ref@mail.yahoo.com>
@ 2024-03-30  2:15 ` Joel via ntg-context
  2024-03-30  9:38   ` [NTG-context] " Henning Hraban Ramm
  0 siblings, 1 reply; 4+ messages in thread
From: Joel via ntg-context @ 2024-03-30  2:15 UTC (permalink / raw)
  To: Mailing List for ConTeXt Users; +Cc: Joel


[-- Attachment #1.1: Type: text/plain, Size: 918 bytes --]

I have code like this:

    \placefigure[here, force]{my caption}{%        \externalfigure[#1][frame=on, maxheight=1.2\textwidth, maxwidth=\textwidth]%
    }%
I need some images to appear in a book. I need them to keep their proper ratios, but scale up to the maximize the available space.
The image can't be more than \textwidth wide, and can't ever be more than 1.2\textwidth high.
The problem I am getting with this code, and it does seem to be limiting the images to be not bigger than those two dimensions above, is some of the images, for reasons I can't understand, are appearing really tiny and aren't scaling up to fill as much space as is possible. I can't explain why this is happening--the images themselves are very very high resolution.
Is there any way to modify the code to make sure the image stretches up to be the biggest it can, without exceeding the sizes I've listed?
--Joel

[-- Attachment #1.2: Type: text/html, Size: 1725 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: How to get an image to fill the maximum available space?
  2024-03-30  2:15 ` [NTG-context] How to get an image to fill the maximum available space? Joel via ntg-context
@ 2024-03-30  9:38   ` Henning Hraban Ramm
  2024-03-30 11:07     ` Bruce Horrocks
  0 siblings, 1 reply; 4+ messages in thread
From: Henning Hraban Ramm @ 2024-03-30  9:38 UTC (permalink / raw)
  To: ntg-context

Am 30.03.24 um 03:15 schrieb Joel via ntg-context:
> I have code like this:
> 
>      \placefigure[here, force]{my caption}{%
>          \externalfigure[#1][frame=on, maxheight=1.2\textwidth, 
> maxwidth=\textwidth]%
>      }%
> 
> I need some images to appear in a book. I need them to keep their proper 
> ratios, but scale up to the maximize the available space.
> 
> The image can't be more than \textwidth wide, and can't ever be more 
> than 1.2\textwidth high.
> 
> The problem I am getting with this code, and it does seem to be limiting 
> the images to be not bigger than those two dimensions above, is some of 
> the images, for reasons I can't understand, are appearing really tiny 
> and aren't scaling up to fill as much space as is possible. I can't 
> explain why this is happening--the images themselves are very very high 
> resolution.
> 
> Is there any way to modify the code to make sure the image stretches up 
> to be the biggest it can, without exceeding the sizes I've listed?

Hi Joel,

AFAIK, if you don’t set at least either height or width, ConTeXt uses 
the image’s resolution setting to calculate its size, and that is often 
useless.

(Maybe there’s also something wrong with ConTeXt’s max width/height, I 
don’t know; I’m still planning to carefully check all options of image 
processing…)

You could try if "factor=fit" or "factor=max" yields the results you want.

Hraban
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: How to get an image to fill the maximum available space?
  2024-03-30  9:38   ` [NTG-context] " Henning Hraban Ramm
@ 2024-03-30 11:07     ` Bruce Horrocks
  2024-03-30 18:23       ` Hans Hagen
  0 siblings, 1 reply; 4+ messages in thread
From: Bruce Horrocks @ 2024-03-30 11:07 UTC (permalink / raw)
  To: ntg-context mailing list



> On 30 Mar 2024, at 09:38, Henning Hraban Ramm <texml@fiee.net> wrote:
> 
> Am 30.03.24 um 03:15 schrieb Joel via ntg-context:
>> I have code like this:
>>     \placefigure[here, force]{my caption}{%
>>         \externalfigure[#1][frame=on, maxheight=1.2\textwidth, maxwidth=\textwidth]%
>>     }%
>> I need some images to appear in a book. I need them to keep their proper ratios, but scale up to the maximize the available space.
>> The image can't be more than \textwidth wide, and can't ever be more than 1.2\textwidth high.
>> The problem I am getting with this code, and it does seem to be limiting the images to be not bigger than those two dimensions above, is some of the images, for reasons I can't understand, are appearing really tiny and aren't scaling up to fill as much space as is possible. I can't explain why this is happening--the images themselves are very very high resolution.
>> Is there any way to modify the code to make sure the image stretches up to be the biggest it can, without exceeding the sizes I've listed?
> 
> Hi Joel,
> 
> AFAIK, if you don’t set at least either height or width, ConTeXt uses the image’s resolution setting to calculate its size, and that is often useless.
> 
> (Maybe there’s also something wrong with ConTeXt’s max width/height, I don’t know; I’m still planning to carefully check all options of image processing…)
> 
> You could try if "factor=fit" or "factor=max" yields the results you want.

As Hraban says, you only need to set one of height or width and Context works out the other.

For your case I think you just need width=\textwidth, so

  \externalfigure[#1][frame=on,width=\textwidth,maxheight=1.2\textwidth]%

where maxheight imposes the height size limit you mention.

If you still have problems with tiny images then I suspect that is a different issue - something to do with the image file and the metadata about the image size maybe? If you can share an affected image then perhaps start another question with an MWE and upload the image somewhere.

Regards,
—
Bruce Horrocks
Hampshire, UK

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: How to get an image to fill the maximum available space?
  2024-03-30 11:07     ` Bruce Horrocks
@ 2024-03-30 18:23       ` Hans Hagen
  0 siblings, 0 replies; 4+ messages in thread
From: Hans Hagen @ 2024-03-30 18:23 UTC (permalink / raw)
  To: ntg-context

On 3/30/2024 12:07 PM, Bruce Horrocks wrote:
> 
> 
>> On 30 Mar 2024, at 09:38, Henning Hraban Ramm <texml@fiee.net> wrote:
>>
>> Am 30.03.24 um 03:15 schrieb Joel via ntg-context:
>>> I have code like this:
>>>      \placefigure[here, force]{my caption}{%
>>>          \externalfigure[#1][frame=on, maxheight=1.2\textwidth, maxwidth=\textwidth]%
>>>      }%
>>> I need some images to appear in a book. I need them to keep their proper ratios, but scale up to the maximize the available space.
>>> The image can't be more than \textwidth wide, and can't ever be more than 1.2\textwidth high.
>>> The problem I am getting with this code, and it does seem to be limiting the images to be not bigger than those two dimensions above, is some of the images, for reasons I can't understand, are appearing really tiny and aren't scaling up to fill as much space as is possible. I can't explain why this is happening--the images themselves are very very high resolution.
>>> Is there any way to modify the code to make sure the image stretches up to be the biggest it can, without exceeding the sizes I've listed?
>>
>> Hi Joel,
>>
>> AFAIK, if you don’t set at least either height or width, ConTeXt uses the image’s resolution setting to calculate its size, and that is often useless.
>>
>> (Maybe there’s also something wrong with ConTeXt’s max width/height, I don’t know; I’m still planning to carefully check all options of image processing…)
>>
>> You could try if "factor=fit" or "factor=max" yields the results you want.
> 
> As Hraban says, you only need to set one of height or width and Context works out the other.
> 
> For your case I think you just need width=\textwidth, so
> 
>    \externalfigure[#1][frame=on,width=\textwidth,maxheight=1.2\textwidth]%
> 
> where maxheight imposes the height size limit you mention.
> 
> If you still have problems with tiny images then I suspect that is a different issue - something to do with the image file and the metadata about the image size maybe? If you can share an affected image then perhaps start another question with an MWE and upload the image somewhere.
% \externalfigure
%     [t:/sources/cow.pdf]
%     [frame=on,factor=max]

\externalfigure
     [t:/sources/mill.png]
     [frame=on,factor=max,maxwidth=\textwidth,maxheight=.8\textheight]


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2024-03-30 18:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <702755847.2028514.1711764942052.ref@mail.yahoo.com>
2024-03-30  2:15 ` [NTG-context] How to get an image to fill the maximum available space? Joel via ntg-context
2024-03-30  9:38   ` [NTG-context] " Henning Hraban Ramm
2024-03-30 11:07     ` Bruce Horrocks
2024-03-30 18:23       ` Hans Hagen

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 NNTP newsgroup(s).