I'm using luatatex 1.0.4 on Linux.

I read several articles about directly converting image files within the LaTeX process. But somehow I fail to use it properly for converting gif-files on the fly. I have the following folder structure:

+   main folder
-+ image folder

the abc.tex contains simply


and the main.tex has

\usepackage{arabluatex} % for support of arabic fonts
%\DeclareGraphicsExtensions{.gif, .ps, .eps, .png}
  convert #1 \OutputFile         
%\epstopdfDeclareGraphicsRule{.gif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .gif`-gif-converted-to.png}
%\epstopdfDeclareGraphicsRule{.gif}{png}{.png}{mogrify -format png}
%\epstopdfDeclareGraphicsRule{.gif}{png}{.png}{`convert #1 `basename #1 .gif`-gif-converted-to.png}
%\epstopdfDeclareGraphicsRule{.gif}{png}{.png}{`convert #1 -set filename:base "\%[basename]" "\%[filename:base]-gif-converted-to.png"}

Include gif-Image

If I comment the package arabluatex than I cannot compile cause Undefined control sequence. \epstopdfDeclareGraphicsRule. If I leave it on the log-file says:

Package epstopdf Info: Source file: <./images/MySample.gif>
(epstopdf)                    date: 2019-01-21 14:32:08
(epstopdf)                    size: 835 bytes
(epstopdf)             Output file: <./images/MySample-gif-converted-to.png>
(epstopdf)             Command: <`convert ./images/MySample.gif `dirname ./image
s/MySample.gif`/`basename ./images/MySample.gif .gif`-gif-converted-to.png>
(epstopdf)             \includegraphics on input line 3.
system(`convert ./images/MySample.gif `dirname ./images/MySample.gif`/`basename 
./images/MySample.gif .gif`-gif-converted-to.png) executed.
Package epstopdf Info: Result file: <./images/MySample-gif-converted-to.png>.

! Package luatex.def Error: File `./images/MySample-gif-converted-to.png' not f

From the logs I would conclude the conversion is done. I tried the different commented approaches but none of them succeeded.

  • Under Linux, why not install Image Magick or the fork Graphics Magick and convert all GIFs to PNGs in the command line manually? It is actually easier, except if your GIFs change a lot. – Martin Scharrer Jan 22 at 8:24
  • `convert #1 `dirname #1`/`basename #1 .gif`-gif-converted-to.png looks wrong, the ` should at least be before the .gif or the space should be gone. – Martin Scharrer Jan 22 at 8:26
  • Try first without some complicated directory structure. – Ulrike Fischer Jan 22 at 8:44
  • The reason for inlining it is that the conversion is done automatically. Therefore the command line is nice but not usable for my scenario. Honestly I do not understand how to write it properly, e.g. `convert #1 `dirname #1`/`basename #1.-gif-converted-to.png does not help neither :-( I do not get any kind of converted pics neither in the folder nor in its sub. – LeO Jan 22 at 8:45
  • you need to use --shell-escape which is a security risk unless you have full knowledge of all the tex code, and you convert the file every time which is slow, why not simply run convert before running tex? The eps to pdf conversion is different as it is allowed to run without --shell-escape using a restricted version of ghostscript running in safe mode – David Carlisle Jan 22 at 10:55

You can use the same graphics rule you already use for .tif, so

  convert #1 \OutputFile         

Include gif-Image

works fine. The epstopdf package does not rely on LuaTeX, it works with pdfTeX too because it is based on shell commands. To allow TeX to execute arbitrary shell commands like convert, you have to compile the document with shell-escape enabled, so run

lualatex -shell-escape main

instead of

lualatex main
  • Thx for this hint (shell-escape) cause I didn't find it properly. This saved my day :-) – LeO Jan 22 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.