ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Alan Braslau via ntg-context <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
	Hans Hagen <j.hagen@xs4all.nl>
Cc: Alan Braslau <alan.braslau@icloud.com>
Subject: [NTG-context] Re: access image properties in Lua
Date: Mon, 17 Jul 2023 15:44:34 +0200	[thread overview]
Message-ID: <2784af61-7a02-22e4-31b7-5a63cacdf0d0@icloud.com> (raw)
In-Reply-To: <4794a877-7380-e1d5-b673-6770f824c7ac@xs4all.nl>

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	other threads:[~2023-07-17 13:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-11 12:22 Henning Hraban Ramm
2023-07-13  7:19 ` Hans Hagen
2023-07-17 13:44   ` Alan Braslau via ntg-context [this message]
2023-07-17 16:20     ` [NTG-context] " Henning Hraban Ramm
2023-07-17 17:10       ` Alan Braslau via ntg-context
     [not found]       ` <048d051e-c66f-3e0f-e3d2-48ef300b7280@icloud.com>
2023-07-18 11:39         ` Henning Hraban Ramm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2784af61-7a02-22e4-31b7-5a63cacdf0d0@icloud.com \
    --to=ntg-context@ntg.nl \
    --cc=alan.braslau@icloud.com \
    --cc=j.hagen@xs4all.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).