[NTG-context] Multiple image conversions

Marco Patzer lists at homerow.info
Sun Dec 16 21:18:43 CET 2018


Hi!

I wonder if/how it's possible to specify multiple image conversions. Example:

\startluacode
  local format = string.format
  local function degradejpg(oldname, newname)
    local s = format("gm convert -strip -quality 75%% -resize '300x300>' %s %s", oldname, newname)
    os.execute(s)
  end
  local function degradepng(oldname, newname)
    local s = format("gm convert -strip -resize '500x500>' %s %s", oldname, newname)
    os.execute(s)
  end
  figures.converters.jpg["degrade.jpg"] = degradejpg
  figures.converters.png["degrade.png"] = degradepng
\stopluacode

\setupexternalfigures
  [location=default,
   %% conversion=degrade.png, %% how to use both?
   conversion=degrade.jpg]

\starttext
  \externalfigure [hacker]
  \externalfigure [mill]
\stoptext

I'd like to avoid specifying the filetype-specific conversion with each
\externalfigure command:

  %% this works, but it clutters the document and one has to check the
  %% file type each time
  \externalfigure [mill] [conversion=degrade.png]

Marco


More information about the ntg-context mailing list