From: Hans Hagen <pragma@wxs.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: fitting a picture to the available space
Date: Thu, 11 Sep 2008 09:28:42 +0200 [thread overview]
Message-ID: <48C8C8AA.8080003@wxs.nl> (raw)
In-Reply-To: <396E487E-2550-48FB-BF43-BC51ED2388F4@uni-bonn.de>
Thomas A. Schmitz wrote:
> Hi guys,
>
> I'm pulling my hair out. I'm trying to set up an automatism to fit
> pictures to the available space on a slide. I need to consider three
> parameters:
>
> 1. If the user supplies a value for width= or height= , use this value
> (captured in a macro);
>
> 2. respect the maxwidth and maxheight which must not exceed the frame;
>
> 3. if the picture is smaller than the available space, blow it up so
> that it reaches the maxwidth or maxheight (but doesn't exceed either).
>
> factor=max or =fit does not work because it allows pictures to exceed
> one of the maximum values. About a year ago Giuseppe Bilotta wrote a
> message which I append; it describes my problem. Is there a generic
> solution for this problem? If there is, I'll gladly take it; if there
> isn't, I thought I had a solution but may need help with expanding and
> conditionals, then I'll be back with more questions.
>
> Anyway, good night all, and thanks.
\starttext
\framed[width=5cm,height4cm]{\externalfigure[mill.png][maxwidth=3cm,maxheight=4cm,width=10cm]}
\stoptext
seems to work
> Thomas
>
>> Subject: Re: [NTG-context] factor=fit images don't fit
>> Sunday, July 22, 2007 Hans Hagen wrote:
>>
>>> the fit assumes operating on a page not in a box;
>> Ah, didn't know that. I couldn't even tell from the sources,
>> since it uses enclosing box dimensions and not page or paper
>> sizes. I suspect the logic is broken at the page level too
>> though, let me explain why.
>>
>> Currently, if I understand the code correctly, factor=fit
>> expands the figure to have its major direction fit, while
>> factor=max expands the figure to have its minor direction
>> fit.
>>
>> Instead, the behavior I would expect from fit (resp. max) is
>> for the *expansion ratio* to be the minimum (resp. maximum)
>> of the expansion ratios in the two directions (not the sizes
>> in those directions, but the ratio between the sizes of the
>> figure and the container). The difference is noticeable when
>> the container and contained have different aspect ratios.
>>
>> Consider for example a 20x30mm figure in a 50x150mm page
>> (strange numbers, just used to show what I mean): with the
>> current code, using 'fit' would consider the largest
>> dimension (30) and thus calculate a factor of 150/30 = 5,
>> but this gives us an image which is 100x150mm, i.e. an image
>> that doesn't fit! Whereas, if we computed the ratios 50/20 =
>> 2.5 and 150/30 = 5, we would know that the ratio to be
>> picked was 2.5 in 'fit' and 5 in 'max'.
>>
>> Or I misintepreting the meaning of 'fit' and 'max'?
>>
>>> an alternative is:
>>> \framed[width=5cm,height4cm]
>>>
>>> {\externalfigure[mill.png][maxwidth=4cm,maxheight=5cm,width=10cm]}
>>> i.e. setting the maximum values
>> I hadn't thought about using width and maxwidth (and
>> maxheight) at the same time, thanks. Of course, I'd rather
>> have 'fit' and 'max' usable in boxes :)
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive : https://foundry.supelec.fr/projects/contextrev/
> wiki : http://contextgarden.net
> ___________________________________________________________________________________
--
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| 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 / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2008-09-11 7:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-10 22:06 Thomas A. Schmitz
2008-09-11 7:28 ` Hans Hagen [this message]
2008-09-11 8:04 ` Thomas A. Schmitz
2008-09-11 13:28 ` Thomas A. Schmitz
2008-09-11 14:01 ` Peter Rolf
2008-09-11 14:40 ` Thomas A. Schmitz
2008-09-11 14:56 ` Hans Hagen
2008-09-11 14:13 ` Wolfgang Schuster
2008-09-11 16:20 ` Thomas A. Schmitz
2008-09-11 16:39 ` Hans Hagen
2008-09-11 17:59 ` Thomas A. Schmitz
2008-09-11 21:50 ` Thomas A. Schmitz
2008-09-12 7:14 ` Wolfgang Schuster
2008-09-12 12:37 ` Thomas A. Schmitz
2008-09-11 16:31 ` Mojca Miklavec
2008-09-12 10:02 ` Wolfgang Schuster
2008-09-12 15:20 ` Mojca Miklavec
2008-09-12 15:37 ` 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=48C8C8AA.8080003@wxs.nl \
--to=pragma@wxs.nl \
--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).