ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Scale image in MetaPost, maintaining aspect ratio
@ 2018-07-07 18:58 Marco Patzer
  2018-07-07 20:27 ` Alan Braslau
  2018-07-07 20:27 ` Hans Hagen
  0 siblings, 2 replies; 9+ messages in thread
From: Marco Patzer @ 2018-07-07 18:58 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi!

How to scale an image in MetaPost, maintaining the aspect ratio
(without specifying the height explicitly)?

Example:

\setupexternalfigures [location=default]
\starttext
  \externalfigure [cow][width=5cm]

  \startMPcode
    draw externalfigure "cow" scaled 5cm;
  \stopMPcode
\stoptext

Marco
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Scale image in MetaPost, maintaining aspect ratio
  2018-07-07 18:58 Scale image in MetaPost, maintaining aspect ratio Marco Patzer
@ 2018-07-07 20:27 ` Alan Braslau
  2018-07-07 23:45   ` Marco Patzer
  2018-07-07 20:27 ` Hans Hagen
  1 sibling, 1 reply; 9+ messages in thread
From: Alan Braslau @ 2018-07-07 20:27 UTC (permalink / raw)
  To: Marco Patzer; +Cc: mailing list for ConTeXt users

On Sat, 7 Jul 2018 20:58:40 +0200
Marco Patzer <lists@homerow.info> wrote:

> Hi!
> 
> How to scale an image in MetaPost, maintaining the aspect ratio
> (without specifying the height explicitly)?
> 
> Example:
> 
> \setupexternalfigures [location=default]
> \starttext
>   \externalfigure [cow][width=5cm]
> 
>   \startMPcode
>     draw externalfigure "cow" scaled 5cm;
>   \stopMPcode
> \stoptext

For "historic" reasons,
    draw externalfigure "cow" scaled 5cm ;
normalizes the figure to a square. This will not be changed as it is a
very old feature of MetaFun.

The solution is
    draw rawtextext("\externalfigure[cow]") xsized 5cm ;
where one can use xsized, ysized or xysized (taking a pair).

Alan
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Scale image in MetaPost, maintaining aspect ratio
  2018-07-07 18:58 Scale image in MetaPost, maintaining aspect ratio Marco Patzer
  2018-07-07 20:27 ` Alan Braslau
@ 2018-07-07 20:27 ` Hans Hagen
  2018-07-07 23:35   ` Marco Patzer
  1 sibling, 1 reply; 9+ messages in thread
From: Hans Hagen @ 2018-07-07 20:27 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 7/7/2018 8:58 PM, Marco Patzer wrote:
> Hi!
> 
> How to scale an image in MetaPost, maintaining the aspect ratio
> (without specifying the height explicitly)?
> 
> Example:
> 
> \setupexternalfigures [location=default]
> \starttext
>    \externalfigure [cow][width=5cm]
> 
>    \startMPcode
>      draw externalfigure "cow" scaled 5cm;
>    \stopMPcode
> \stoptext
it's all in the metafun manual

xsized 5cm

-----------------------------------------------------------------
                                           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 / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Scale image in MetaPost, maintaining aspect ratio
  2018-07-07 20:27 ` Hans Hagen
@ 2018-07-07 23:35   ` Marco Patzer
  0 siblings, 0 replies; 9+ messages in thread
From: Marco Patzer @ 2018-07-07 23:35 UTC (permalink / raw)
  To: ntg-context

On Sat, 7 Jul 2018 22:27:51 +0200
Hans Hagen <j.hagen@xs4all.nl> wrote:

> On 7/7/2018 8:58 PM, Marco Patzer wrote:
> > Hi!
> > 
> > How to scale an image in MetaPost, maintaining the aspect ratio
> > (without specifying the height explicitly)?
> > 
> > Example:
> > 
> > \setupexternalfigures [location=default]
> > \starttext
> >    \externalfigure [cow][width=5cm]
> > 
> >    \startMPcode
> >      draw externalfigure "cow" scaled 5cm;
> >    \stopMPcode
> > \stoptext
> it's all in the metafun manual

No doubts about that. It's more a matter of knowing what to search
for.

> xsized 5cm

I tried it, same result - square image:

  draw externalfigure "cow" xsized 5cm;

As Alan mentioned including the image with textext() works. Not as
elegant, but it gets the job done.

Marco
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Scale image in MetaPost, maintaining aspect ratio
  2018-07-07 20:27 ` Alan Braslau
@ 2018-07-07 23:45   ` Marco Patzer
  2018-07-08  8:39     ` Hans Hagen
  0 siblings, 1 reply; 9+ messages in thread
From: Marco Patzer @ 2018-07-07 23:45 UTC (permalink / raw)
  To: ntg-context

On Sat, 7 Jul 2018 14:27:38 -0600
Alan Braslau <braslau.list@comcast.net> wrote:

> For "historic" reasons,
>     draw externalfigure "cow" scaled 5cm ;
> normalizes the figure to a square. This will not be changed as it is a
> very old feature of MetaFun.
> 
> The solution is
>     draw rawtextext("\externalfigure[cow]") xsized 5cm ;
> where one can use xsized, ysized or xysized (taking a pair).

That works indeed. Thanks.

Marco
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Scale image in MetaPost, maintaining aspect ratio
  2018-07-07 23:45   ` Marco Patzer
@ 2018-07-08  8:39     ` Hans Hagen
  2018-07-08  9:02       ` Marco Patzer
  0 siblings, 1 reply; 9+ messages in thread
From: Hans Hagen @ 2018-07-08  8:39 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Marco Patzer

On 7/8/2018 1:45 AM, Marco Patzer wrote:
> On Sat, 7 Jul 2018 14:27:38 -0600
> Alan Braslau <braslau.list@comcast.net> wrote:
> 
>> For "historic" reasons,
>>      draw externalfigure "cow" scaled 5cm ;
>> normalizes the figure to a square. This will not be changed as it is a
>> very old feature of MetaFun.
>>
>> The solution is
>>      draw rawtextext("\externalfigure[cow]") xsized 5cm ;
>> where one can use xsized, ysized or xysized (taking a pair).
> 
> That works indeed. Thanks.
draw figure "...." ...



-----------------------------------------------------------------
                                           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 / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Scale image in MetaPost, maintaining aspect ratio
  2018-07-08  8:39     ` Hans Hagen
@ 2018-07-08  9:02       ` Marco Patzer
  2018-07-08  9:21         ` Hans Hagen
  0 siblings, 1 reply; 9+ messages in thread
From: Marco Patzer @ 2018-07-08  9:02 UTC (permalink / raw)
  To: Hans Hagen; +Cc: mailing list for ConTeXt users

On Sun, 8 Jul 2018 10:39:52 +0200
Hans Hagen <j.hagen@xs4all.nl> wrote:

> On 7/8/2018 1:45 AM, Marco Patzer wrote:
> > On Sat, 7 Jul 2018 14:27:38 -0600
> > Alan Braslau <braslau.list@comcast.net> wrote:
> >   
> >> For "historic" reasons,
> >>      draw externalfigure "cow" scaled 5cm ;
> >> normalizes the figure to a square. This will not be changed as it
> >> is a very old feature of MetaFun.
> >>
> >> The solution is
> >>      draw rawtextext("\externalfigure[cow]") xsized 5cm ;
> >> where one can use xsized, ysized or xysized (taking a pair).  
> > 
> > That works indeed. Thanks.  
> draw figure "...." ...

That's what I was looking for. Thanks.

Marco
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Scale image in MetaPost, maintaining aspect ratio
  2018-07-08  9:02       ` Marco Patzer
@ 2018-07-08  9:21         ` Hans Hagen
  2018-07-08 15:49           ` Alan Braslau
  0 siblings, 1 reply; 9+ messages in thread
From: Hans Hagen @ 2018-07-08  9:21 UTC (permalink / raw)
  To: Marco Patzer; +Cc: mailing list for ConTeXt users

On 7/8/2018 11:02 AM, Marco Patzer wrote:
> On Sun, 8 Jul 2018 10:39:52 +0200
> Hans Hagen <j.hagen@xs4all.nl> wrote:
> 
>> On 7/8/2018 1:45 AM, Marco Patzer wrote:
>>> On Sat, 7 Jul 2018 14:27:38 -0600
>>> Alan Braslau <braslau.list@comcast.net> wrote:
>>>    
>>>> For "historic" reasons,
>>>>       draw externalfigure "cow" scaled 5cm ;
>>>> normalizes the figure to a square. This will not be changed as it
>>>> is a very old feature of MetaFun.
>>>>
>>>> The solution is
>>>>       draw rawtextext("\externalfigure[cow]") xsized 5cm ;
>>>> where one can use xsized, ysized or xysized (taking a pair).
>>>
>>> That works indeed. Thanks.
>> draw figure "...." ...
> 
> That's what I was looking for. Thanks.
the "externalfigure" variant is an old one that had to deal with 
dimensions in a way that avoids overflows

in a future context (read luatex 1.09+) we go one-pass-mp so we can have 
a different approach (i never wanted to add a ton of code for images) so 
there externalfigure will scale proportionally too

Hans


-----------------------------------------------------------------
                                           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 / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Scale image in MetaPost, maintaining aspect ratio
  2018-07-08  9:21         ` Hans Hagen
@ 2018-07-08 15:49           ` Alan Braslau
  0 siblings, 0 replies; 9+ messages in thread
From: Alan Braslau @ 2018-07-08 15:49 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Sun, 8 Jul 2018 11:21:55 +0200
Hans Hagen <j.hagen@xs4all.nl> wrote:

> the "externalfigure" variant is an old one that had to deal with 
> dimensions in a way that avoids overflows
> 
> in a future context (read luatex 1.09+) we go one-pass-mp so we can
> have a different approach (i never wanted to add a ton of code for
> images) so there externalfigure will scale proportionally too

ConTeXt running on the luatex experimental branch under development
indeed works with one-pass-MP calculations as opposed to the two-pass
mechanism that is standard today. For documents with extensive and
complicated MP graphics, this yields a huge gain. Hans is at present
working out all side-effects (such as recursive MP/TeX/lua calls) and is
cleaning up some old ways of doing things that date from mkii. This
might seem somewhat minor but is really exciting for those who use a
lot of graphics and MetaPost effects.

Alan
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2018-07-08 15:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-07 18:58 Scale image in MetaPost, maintaining aspect ratio Marco Patzer
2018-07-07 20:27 ` Alan Braslau
2018-07-07 23:45   ` Marco Patzer
2018-07-08  8:39     ` Hans Hagen
2018-07-08  9:02       ` Marco Patzer
2018-07-08  9:21         ` Hans Hagen
2018-07-08 15:49           ` Alan Braslau
2018-07-07 20:27 ` Hans Hagen
2018-07-07 23:35   ` Marco Patzer

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).