summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkxl/libs-imp-graphicsmagick.lmt
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-03-06 21:58:15 +0000
committerKarl Berry <karl@freefriends.org>2021-03-06 21:58:15 +0000
commit974640d66e61e81cb197ad96fdff7b08343e4c5a (patch)
tree2e1f75f32f312b7f24ba82b4590ae230bcd6f399 /Master/texmf-dist/tex/context/base/mkxl/libs-imp-graphicsmagick.lmt
parentb4fa72e61230aca75f7f6fbf988821f71edfb6b2 (diff)
context
git-svn-id: svn://tug.org/texlive/trunk@58167 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkxl/libs-imp-graphicsmagick.lmt')
-rw-r--r--Master/texmf-dist/tex/context/base/mkxl/libs-imp-graphicsmagick.lmt77
1 files changed, 77 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkxl/libs-imp-graphicsmagick.lmt b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-graphicsmagick.lmt
new file mode 100644
index 00000000000..6f5d1d967fd
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-graphicsmagick.lmt
@@ -0,0 +1,77 @@
+if not modules then modules = { } end modules ['libs-imp-graphicsmagick'] = {
+ version = 1.001,
+ comment = "companion to luat-lib.mkxl",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+local libname = "graphicsmagick"
+local libfile = { "CORE_RL_magick_", "CORE_RL_wand_" }
+
+local gmlib = resolvers.libraries.validoptional(libname)
+
+if not gmlib then return end
+
+local function okay()
+ if resolvers.libraries.optionalloaded(libname,libfile) then
+ okay = function() return true end
+ else
+ okay = function() return false end
+ end
+ return okay()
+end
+
+local graphicsmagick = utilities.graphicsmagick or { }
+utilities.graphicsmagick = graphicsmagick
+utilities.graphicmagick = graphicsmagick
+
+local gm_execute = gmlib.execute
+local nofruns = 0
+local report = logs.reporter(libname)
+
+function graphicsmagick.convert(specification)
+ if okay() then
+ --
+ nofruns = nofruns + 1
+ statistics.starttiming(graphicsmagick)
+ --
+ local inputname = specification.inputname
+ if not inputname or inputname == "" then
+ report("invalid run %s, no inputname specified",nofruns)
+ statistics.stoptiming(graphicsmagick)
+ return false
+ end
+ local outputname = specification.outputname
+ if not outputname or outputname == "" then
+ outputname = file.replacesuffix(inputname,"pdf")
+ end
+ --
+ if not lfs.isfile(inputname) then
+ report("invalid run %s, input file %a is not found",nofruns,inputname)
+ statistics.stoptiming(graphicsmagick)
+ return false
+ end
+ --
+ report("run %s, input file %a, outputfile %a",nofruns,inputname,outputname)
+ --
+ gm_execute { inputfile = inputname, outputfile = outputname }
+ --
+ statistics.stoptiming(graphicsmagick)
+ end
+end
+
+function graphicsmagick.statistics(report)
+ local runtime = statistics.elapsedtime(graphicsmagick)
+ if report then
+ report("nofruns %s, runtime %s",nofruns,runtime)
+ else
+ return {
+ runtime = runtime,
+ nofruns = nofruns,
+ }
+ end
+end
+
+-- graphicsmagick.convert { inputname = "t:/sources/hacker.jpg", outputname = "e:/tmp/hacker.png" }
+-- graphicsmagick.statistics(true)