The order of preference when files with the same name and different extensions is
.png .pdf .jpg .mps .jpeg .jbig2 .jb2 .PNG .PDF .JPG .JPEG .JBIG2 .JB2
which is stored in the macro \Gin@extensions
. So if you have both image.png
and image.pdf
, pdflatex
will load the former.
If you are mixing case in extensions, then
\DeclareGraphicsExtensions{%
.png,.PNG,%
.pdf,.PDF,%
.jpg,.mps,.jpeg,.jbig2,.jb2,.JPG,.JPEG,.JBIG2,.JB2}
will ensure that PNG are always preferred over PDF files. For the final version it will be sufficient to switch the two lines.
A handier way, suggested by Heiko Oberdiek, is to use the package grfext
:
\usepackage{grfext}
\PrependGraphicsExtensions*{.png,.PNG}
that will have the same effect without the need to check in pdftex.def
for the list of extensions.
If you want also automatic conversion, you can say
\usepackage{graphicx}
\usepackage{epstopdf}
\epstopdfDeclareGraphicsRule{.pdf}{png}{.png}{convert #1 \OutputFile}
\DeclareGraphicsExtensions{%
.png,.PNG,%
.pdf,.PDF,%
.jpg,.mps,.jpeg,.jbig2,.jb2,.JPG,.JPEG,.JBIG2,.JB2}
When image.pdf
exists but not image.png
, the file image-pdf-converted-to.png
will be created and loaded in its place. Add the options you prefer between convert
and #1
(for example -density 100
or something like that).
You need to call pdflatex
with the --shell-escape
option for this automatic conversion to work. Of course you'll comment out the \epstopdfDeclareGraphicsRule
command for the final version, when only PDF files should be loaded (and switch the order of precedence in the lines below).
Best Answer
This is what I recommend:
I work with pdflatex.
Examples
Here's a photo. As JPEG it is about 140 KB and as PNG it is about 1200 KB. You cant't tell the difference:
JPEG
PNG
The next picture is a screenshot. As PNG it is clear - every pixel is exactly correct. The PNG size is 41 KB. The JPEG (I used a high compression obviously) is only 10 KB but you get artifacts. A PNG file will not loose information unless you change the resolution.
PNG
JPEG (high compression)