[NTG-context] Scale image in MetaPost, maintaining aspect ratio

Marco Patzer lists at homerow.info
Sun Jul 8 01:35:18 CEST 2018


On Sat, 7 Jul 2018 22:27:51 +0200
Hans Hagen <j.hagen at 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


More information about the ntg-context mailing list