# File format preference with graphicx

I'm using Mathematicato produce some of my graphics (when i'm not able to just TikZ them easily). All these images are availabvle as .eps and .pnghaving the same file name - let's use img.eps / img.png in the following.

I would like to set a preference for graphicx to use only one type, i.e. using

\includegraphics[width=.6\textwitdh]{img}

I would like to specify, which img to use with one switch, (package) option or variable.

I tried

\DeclareGraphicsExtension{.eps}

to restrict the allowed image extension to .eps, but still the .png file is included. It seems, .pngis preferred over .eps.

Though this is of course restricted to XeTeX it might be interesting for others, if you use .png together with some lossy format like .jpg to have a file extension preference.

Is there a package option for that or an easy command (global document option) for that?

To provide an MWE is - I think - difficult, because it would be necessary to provide at least 3 files.

-
–  Werner Jan 1 '13 at 20:28
At least if you have all images available in both formats \RemoveGraphicsExtension from grfext does the job. By removing the unwanted extension. Though, if one of all your images is available only in one format - a preference would be necessary (removing the extension disables to use that specific image). –  Ronny Jan 1 '13 at 20:52
\DeclareGraphicsExtensions{.eps} (note s at end of command name) would make LaTeX only handle .eps explicitly, in particular it should only ever add a .eps extension. (other file types may be handled if their extension is explicit) –  David Carlisle Jan 1 '13 at 21:47
"to TikZ something" sounds quite cool. :-) –  Christian Feuersänger Jan 1 '13 at 21:53
@DavidCarlisle oh, that works quite nice, if you don't mind you just can turn that into an answer, i don't know, why i didn't get that idea, but i haven't found the documentation for those commands... Christian - yeah. I noticed when I typed that, it really does. –  Ronny Jan 1 '13 at 21:58