On 13/07/23 13/07/23, 09:19, Hans Hagen wrote:
On 7/11/2023 2:22 PM, Henning Hraban Ramm wrote:
What’s the current approved way to get image properties within a Lua function?

very old:
local pic = figures.getinfo(figures.current().status.fullname)

used to work in 2019:
local pic = img.scan{filename = figures.current().status.fullname}

if I understand this right, "img" isn’t valid anymore:
"""
token call, execute: grph-imagelib.lua:37: attempt to index a nil value (global 'img')
"""

I’d like to know the pixel size and if possible also the scaled target size of an image; either the "current" one or by name.
\ctxlua{inspect(figures.getinfo("t:/sources/mill.png").used)}

\ctxlua{inspect(figures.getinfo("t:/sources/mill.png").status)}

etc .. no more faking the img lib

Hans

Hraban, Hans, and mailing list.

This is interesting. I would find it useful to be able to report these properties though a tracker - should be fairly easy if not already available.

One works with images having a certain resolution, whatever that may be. We also might have a target resolution, say 300 dpi or perhaps better for printing. As the images are typically resized when used, the resulting resolutions might be anything. Optimizing the resolutions of the source images can result in optimal PDF sizes, i.e. not too high nor too low resolution.

I can even imagine an automated workflow where high-resolution, say 2400 dpi or even greater bitmap images, are supplied and the included bitmap could be "resampled" resulting in the inclusion of a targeted resolution. However, the reporting of the included, likely resized image resolutions then used to adjust or resample the source files externally and manually case-by-case would be sufficient.

Any suggestions on how to hook-in such reporting?

Bonus question: how also to handle the case of
\startMPcode
draw figure "MyFigure" xsized TextWidth ;
...
\stopMPcode

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

Reply via email to