Ok, I've found a solution.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\enabletrackers[graphics.conversion]
\startluacode
local function convert(oldname, newname)
os.execute(string.format(
'gm convert "%s" "%s"', oldname, newname)
)
end
-- Set the PDF, JPEG and default TIFF converters to the above function.
figures.converters.tif.pdf = convert
figures.converters.tif.jpg = convert
figures.converters.tif.default = convert
\stopluacode
\setfigureconversion[tif][jpg] % has no effect
\starttext
\externalfigure[test.tif][conversion=jpg]
\stoptext
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Would it make sense to add
tifconverter.pdf = converter
to grph-con.lua (line 293) ?
Why is it that \setfigureconversion has no effect? Without conversion=jpg on \externalfigure, ConTeXt insists on converting to PDF. (I couldn't find the command in the sources, but I'm not getting a undef'ed cs error either, so it must be defined somewhere...)
I've also found out I can use a custom command that calls \externalfigure with the right settings depending on the filetype:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\enabletrackers[graphics.conversion]
\startluacode
local function convert(oldname, newname)
os.execute(string.format(
'gm convert "%s" "%s"', oldname, newname)
)
end
-- Set the PDF and default TIFF converters to the above function.
figures.converters.tif.pdf = convert
figures.converters.tif.jpg = convert
figures.converters.tif.default = convert
\stopluacode
\setfigureconversion[tif][jpg] % has no effect
\defineexternalfigure[tif][conversion=jpg]
\starttexdefinition includegraphics #1
\splitfilename{#1}
\processaction[\splitofftype][
tif=>{\externalfigure[#1][tif]},
default=>{\externalfigure[#1]},
unknown=>{\externalfigure[#1]}
]
\stoptexdefinition
\starttext
\includegraphics{test.tif} % will be converted to jpg
\externalfigure[test.tif] % will be converted to pdf
\stoptext
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
But I think it would be nicer to stick to the default \externalfigure.
Best,
Denis
Von: denis.maier@unibe.ch