ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Number of pages by Lua of a figure to be inserted?
@ 2013-04-10 14:22 Procházka Lukáš Ing. - Pontex s. r. o.
  2013-04-10 15:38 ` Hans Hagen
  0 siblings, 1 reply; 3+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2013-04-10 14:22 UTC (permalink / raw)
  To: ConTeXt

Hello,

I need to identify number of pages by Lua of an image which is to be inserted.

The image can be of all various types supported by Ctx - e.g. .png, .pdf.

I've been using the following code so far (based on a mailing thread in the past):

----
function nOfPages(fn)
   local fig = figures.push{name = fn}
     local info = figures.identify()

     figures.check()

     local n = fig.used.pages
   figures.pop()

   return n
end
----

But the code above break Ctx in the case that the image doesn't exist.

I'd need to modify the solution somehow so to return 'nil' or 'false' (or a error message) in the case the file was not found.

How to do it?

TIA.

Best regards,

Lukas

(NB: Still "ConTeXt  ver: 2012.11.26 13:31 MKIV  fmt: 2012.11.27  int: english/english".)


-- 
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o.      [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-04-11  7:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-10 14:22 Number of pages by Lua of a figure to be inserted? Procházka Lukáš Ing. - Pontex s. r. o.
2013-04-10 15:38 ` Hans Hagen
2013-04-11  7:10   ` Procházka Lukáš Ing. - Pontex s. r. o.

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