ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Bruce Horrocks <ntg@scorecrow.com>
To: ntg-context mailing list <ntg-context@ntg.nl>
Subject: [NTG-context] Re: How to get an image to fill the maximum available space?
Date: Sat, 30 Mar 2024 11:07:12 +0000	[thread overview]
Message-ID: <BA79767C-C2D0-4177-9B38-8BF68A08EC7B@scorecrow.com> (raw)
In-Reply-To: <89136f11-5691-435b-bf80-c7368f3a89ea@fiee.net>



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

  reply	other threads:[~2024-03-30 11:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <702755847.2028514.1711764942052.ref@mail.yahoo.com>
2024-03-30  2:15 ` [NTG-context] " Joel via ntg-context
2024-03-30  9:38   ` [NTG-context] " Henning Hraban Ramm
2024-03-30 11:07     ` Bruce Horrocks [this message]
2024-03-30 18:23       ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BA79767C-C2D0-4177-9B38-8BF68A08EC7B@scorecrow.com \
    --to=ntg@scorecrow.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).