[Tex/LaTex] Unable to load picture or PDF file (NEF)

filesgraphics

Under TexWorks XeLaTeX, I try to \includegraphics a .NEF file. I get the error message in the title, except that this includes "(NEF)" for better targetting. Of course, I can convert .NEF to .pdf, .png or other loadable formats. But I have several hundred of these .NEF's, and for final high-quality publication (coffee-table book) I will need that format.
Similar questions have been posed about .tiff images; answers "impossible". Is that still true?

Best Answer

There is no way to directly include TIFF files with pdflatex. The program pdftex used to support some TIFF files, but the developers eventually decided against this, because reall supporting TIFF means supporting tens (perhaps hundreds) different formats. So conversion to PNG seems the only alternative.

I tested the following after downloading a sample NEF file from http://www.luminescentphoto.com/nx2/nefs.html and making sure the dcraw (for GraphicsMagick) or ufraw (for ImageMagick) utilities are available on the machine.

The example file is

\documentclass{article}
\usepackage{graphicx,epstopdf}

\epstopdfDeclareGraphicsRule{.nef}{png}{.png}{%
  % convert #1 \OutputFile  % for ImageMagick (uses ufraw)
  gm convert #1 \OutputFile % for GraphicsMagick (uses dcraw)
}

\begin{document}

\includegraphics[width=5cm]{baby.nef}

\end{document}

to be run with pdflatex -shell-escape.

This will do the conversion on the fly, but just once, producing the file baby-nef-converted-to.png.

Use one of the two lines above depending on what conversion program you have or prefer.

Some figures: the original NEF file is 18 MiB; conversion with dcraw produces a 13 MiB PNG file (8-bit/color); conversion with ufraw produces a 55 MiB PNG file (16-bit/color). Take your pick or adjust the conversion options.