Hello Henning,
This is really interesting, but my original question was about the file path resolver, i.e. how to get "t:/sources/cow.pdf" from just "cow"?
I guess there was a similar question here: https://mailman.ntg.nl/pipermail/ntg-context/2017/088324.html Reading till the end, I deduce one has to collect snippets which appear in the code to build its own "file locator" as no function like "MyExternalFigureLocator()" exists in ConTeXt/Lua API. Some highlights: ----
Personally I use the lua variable named : figures.path
It’s a lua table which contains directories names you provide in directory= in \setupexternalfigures:
for _, path in ipairs(figures.paths) do local figure_file = path .. '/' .. file local doc = lpdf.epdf.load(figure_file) -- assume pdf (just an example) if doc then …. end done
Unfortunately, this code supposes the figure name was passed WITH extension, as no lookup in table-of-valid-extensions is performed (maybe no such table nor iterator exists).
There should be also:
----
local n = "x:/Users/MMi/Akce/I-6_Krusovice.DSP-ZDS/Admin/Jednani/2017-07-07-SU-Rakovnik/ZJ.pdf"
local d = figures.getinfo(n)
inspect(d)
----
And a snippet from another mailing thread:
---- (Hans' answer)
\getfiguredimensions[test.pdf]
\dorecurse {\noffigurepages} {
\getfiguredimensions[test.pdf][page=#1]
\figurenaturalwidth
,\figurenaturalheight,\figureorientation,\figurerotation\par
}
in lua you can either use the img library (see luatex manual) or context
helpers
local data = figures.push("foo.pdf")
figures.identify()
figures.check()
figures.pop()
inspect(data)
i'll add:
function figures.getinfo(name,page)
if type(name) == "string" then
name = { name = name, page = page }
end
if name.name then
local data = figures.push(name)
figures.identify()
figures.check()
figures.pop()
return data
end
end
so that one can do
local n = "ms.pdf"
local d = figures.getinfo(n)
if d then
for i=1,d.used.pages do
local p = figures.getinfo(n,i)
if p then
local u = p.used
print(u.width,u.height,u.orientation)
end
end
end
----
Hope this helps.
Best regards,
Lukas
On Sun, 04 Feb 2018 19:04:28 +0100, Henning Hraban Ramm
Greetlings, Hraban --- http://www.fiee.net http://wiki.contextgarden.net GPG Key ID 1C9B22FD
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / 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 ___________________________________________________________________________________
-- Ing. Lukáš Procházka | mailto:LPr@pontex.cz Pontex s. r. o. | mailto:pontex@pontex.cz | http://www.pontex.cz | IDDS:nrpt3sn Bezová 1658 147 14 Praha 4 Mob.: +420 702 033 396