On Fri, Feb 22, 2019 at 12:59:55PM +0100, Peter Münster wrote:
> On Fri, Feb 22 2019, Rudolf Bahr wrote:
> 
> > The picture sizes in px One gets by invoking for instance graphics Magick's 
> > identify
> > in a lua program:
> 
> Or just img.scan():
> 
> \startluacode
>   local image = img.scan{filename = "my-image.jpg"}
>   logs.report("xsize", image.xsize)
>   logs.report("ysize", image.ysize)
> \stopluacode
> 
> -- 
>            Peter

Hi Peter,

thank you for pointing to img.scan{}! It's indeed shorter than to invoke 
Graphics Magick
in Lua. Remains the conversion of image sizes into pt. There is an example in 
the chapter
"Calculations in Lua" in "https://wiki.contextgarden.net/Image_Placement"; (a 
work in
progress). According to there it's necessary to know the resolution in order to 
convert
image sizes from px to pt which at least I don't know. Mostly I can preset one 
size of
a picture (say the width in pt) to be able to place it on a page and assuming
x-resolution = y-resolution and keeping width-to-height ratio I calculate the 
missing
size (here the height in pt) in Lua by

                                                            picture-height-in-px
asked-picture-height-in-pt = preset-picture-width-in-pt  *  --------------------
                                                            picture-width-in-px

This is simple and normally it suffices for me.

Rudolf

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 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
___________________________________________________________________________________

Reply via email to