I am working on a document and found the line

\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}

I am not sure what it does. Can someone chime in?


That line expects to add .tif support to LaTeX by using ImageMagic (convert executable on Linux; I think on Windows it's called magick) to convert a .tif into a .png before graphics inclusion, because no TeX engine/backend (as far as I know) can include TIFF files natively. That line was probably inspired by this part of grfguide:

command is usually empty, but if non empty it is used in place of the filename in the \special. Within this argument, #1 may be used to denote the filename. Thus using the dvips driver, one may use \DeclareGraphicsRule{.ps.gz}{eps}{.ps.bb}{zcat #1}``

which invokes the zcat command to unzip the .ps.gz file before inclusion. However that line only works for simpler stuff, that can be handled from the backend. More complicated commands like ImageMagick can't be handled by the backend directly, so your \DeclareGraphicsRule line doesn't really work.

You can run that command manually to convert your .tif graphics (that is, if you have any) to .png, or use an automatic solution like here (note that that solution is rather inefficient, because it performs the conversion every time you build the document).

To answer the question in the title more precisely:


declares how the graphics (or graphicx) package should handle a file with extension <ext>. When a graphics file file.<ext> is found, it uses a general graphics <type> (defined by the engine code) to include that file, and uses the <read-file> extension to get bounding box information for the file (usually it's the same as <ext>), and <command> as described above will be passed to the backend for reading and including the graphics file.

  • 1
    The time when grfguide was written was a gentler more trusting era, dvips would run any system command (including convert or mailing your password file to a third party) if presented with a special using the backtick syntax. – David Carlisle Mar 1 at 23:55
  • @DavidCarlisle Absurd times we live in! So nowadays only “safe” executables are run, or none at all? The XeTeX driver does have calls to gunzip using that syntax... – Phelype Oleinik Mar 2 at 0:00
  • 1
    I don't think backtick works at all dvips can handle eps.gz files without help or extra commands and anything else you need to convert first. At the tex level the mechanism of rules still works eg calling eps2pdf from pdftex but the dvips backtick mechansism isn't really usable any more – David Carlisle Mar 2 at 0:09

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.