ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Giuseppe Bilotta <gip.bilotta@iol.it>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: factor=fit images don't fit
Date: Fri, 20 Jul 2007 13:05:01 +0200	[thread overview]
Message-ID: <1912359178.20070720130501@iol.it> (raw)
In-Reply-To: <10310609774.20070720012314@iol.it>

Friday, July 20, 2007 Giuseppe Bilotta wrote:

> Hello all,

> I have to place a number of images into some given-size
> frames in a layer. The images should be scaled
> proportionally to fit into the frame. The code I'm working
> with is:

> \defineframed[framedimg][
>   frame=on,framecolor=elux,
>   background=color,
>   backgroundcolor=white,
>   width=\wdfig,
>   height=\htfigone,
>   offset=overlay,
> ]

> \setlayer[figs][voffset=\nextfigvoff]{%
>   \framedimg{%
>     \externalfigure[#1][
>       factor=fit,
>       % maxwidth=\wdfig,
>       % maxheight=\htfigone,
>       % frame=on,
>     ]%
>   }%
> }%

> where \wdfig, \htfigone are the frame size and \nextfigvoff
> is the vertical offset which must be placed. I've tried
> factor=fit, factor=max, but in both cases I get images which
> cross the boundaries of the frame, mostly in the horizontal
> direction. If I add the maxwidth/maxheight specification,
> images don't get scaled at all.

> I would expect factor=fit to scale the image in such a way
> that the biggest direction fits into the enclosing box,
> while factor=max would scale the image in such a way that
> the smallest direction fits into the enclosing box. Instead,
> in both cases the vertical direction is being fitted, with
> no apparent consideration for the horizontal direction.

> What am I doing wrong and what should I do to fix it?

Ok, I've tried studying the source and I really think that
the way factor scaling is computed is wrong. However, the
fix is nontrivial, and a somewhat thorough checking should
be implemented, with earlier check for the factor value
(fit, max, broad), since the logic selecting which dimension
to scale depends on the kind of scaling.

Anyway, I've found a temporary solutin to my problem by
using a very large value of scale=, coupled with appropriate
maxwidth and maxheight values.

-- 
Giuseppe "Oblomov" Bilotta

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


  reply	other threads:[~2007-07-20 11:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-19 23:23 Giuseppe Bilotta
2007-07-20 11:05 ` Giuseppe Bilotta [this message]
2007-07-21 20:30   ` Brian R. Landy
2007-07-22  8:15     ` Giuseppe Bilotta
2007-07-22 20:47   ` Hans Hagen
2007-07-23  7:33     ` luigi scarso
2007-07-24  6:58       ` Giuseppe Bilotta
2007-07-24  7:27     ` Giuseppe Bilotta
2007-07-24  7:54       ` 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=1912359178.20070720130501@iol.it \
    --to=gip.bilotta@iol.it \
    --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).