I am currently working on a document which i am compiling under both linux and windows. As one of the images I use is a tif image, I'd like to have lualatex converting it on-runtime to a format it understands.
Therefore, I managed to do this under linux using
\DeclareGraphicsRule{.tif}{png}{.png}%
{%
`convert #1 `dirname #1`/`basename #1 .tif`-tif-converted-to.png %
}
\AppendGraphicsExtensions{.tif}
This however is not portable to windows because of the dirname and basename commands (as installing ImageMagick makes convert available).
Therefore, I would like to use the file parsing from latex to do this, but I could not find my way around it. The code I am currently trying to use is :
\makeatletter
\newrobustcmd*\dirname[1]{\filename@parse{#1}\filename@area}%
\newrobustcmd*\basename[1]{\filename@parse{#1}\filename@base}%
\DeclareGraphicsRule{.tif}{png}{.png}%
{%
`convert #1 \dirname{#1}/\basename{#1}-tif-converted-to.png %
}%
\makeatother
\AppendGraphicsExtensions{.tif}
However, \DeclareGraphicsRule seems to just ignore I have used macros in my command.
So my question is the following :
- What am I doing wrong ?
- Is there a way around it ?
EDIT : Slightly changing the working command
\filename@parsewouldn't work anyway ? Secondly, when testing your answer I discovered that in fact,#1doesn't seem to contain the extention under linux. Is it the same under every system (in which case it means I'm dumb and my question souldn't even be there in the first place -_-") ? – Samuel Albert Aug 13 '12 at 13:09