[luatex] howto: scaling an image

Patrick Gundlach patrick at gundla.ch
Sun Mar 21 22:21:08 CET 2010


Am 21.03.2010 um 21:50 schrieb Hartmut Henkel:

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

No:

local hacker = img.scan{filename = "hacker.jpg"}

hacker.width  = hacker.width * 0.5
node.write(img.node(hacker))

gives me a distorted image.

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

I'd guess bp. But I don't know.

print(string.format("xsize=%d, ysize=%d",hacker.xsize,hacker.ysize)):

xsize=531, ysize=354


Patrick



More information about the luatex mailing list