On 3/30/2024 12:07 PM, Bruce Horrocks wrote:


On 30 Mar 2024, at 09:38, Henning Hraban Ramm <te...@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
___________________________________________________________________________________

Reply via email to