[luatex] howto: scaling an image

Hartmut Henkel hartmut_henkel at gmx.de
Sun Mar 21 21:50:54 CET 2010

On Sun, 21 Mar 2010, Patrick Gundlach wrote:

> > When I load an image with img.new({filename=...}) I don't have
> > access to the width/height or xsize/ysize before I turn the image
> > into a node. Once it is a whatsit node, I have (as far as I
> > understand) two alternatives:
> I see that with img.scan I get the data, so I'd guess that just
> changing img.width and img.height should do it, right?

yes. or only one of these to keep the aspect ratio.

> > 1) wrap the image in a (scale_x 0 0 scale_y 0 0) matrix or
> > 2) change the width or height and again turn the image into a node.
> >
> > Which one is the preferred way?
> > Oh, an additional question: what are the units of the img.xsize and
> > img.ysize table values?

just sp, isn't it? With pixel images these are calculated from the
number of horizontal/vertical pixels and the x/y resolutions, with the
same heuristics as with pdftex.

Regards, Hartmut

More information about the luatex mailing list