[Tex/LaTex] Include PDF images with interpolate=true

graphicspdf

I was happy to read that \includegraphics allows setting the interpolate flag for imported images:

\includegraphics[interpolate]{testimg}

This works wonderfully if testimg is a PNG image. Unfortunately, it does not work if testimg is a PDF image (example pdf image).

Is there any way to import PDF images and have their interpolate flag be true?

Best Answer

Expanding my comment into an answer:

Any raster objects in a PDF are put inside a container so they appear vectorized, since PDF is natively a vector format. So from the point of view of graphicx, the image is already vectorized, even though it's technically not, only encapsulated by a vector format.

The only way to get interpolation in a PDF would be to produce it before the PDF is produced from the raster graphic. Or simply include the original raster graphic in a raster format supported by graphicx, with appropriate compression applied if needed.

The example requires --shell-escape, ImageMagick, and a copy of example-image-a.png (from the mwe package) placed in the same directory as the example's .tex file:

\documentclass{article}
\usepackage{mwe}
\setkeys{Gin}{width=0.75in}

\begin{document}
\immediate\write18{convert example-image-a.png fromraster.pdf}
\includegraphics{image-a.png}
\includegraphics[interpolate]{fromraster}
\includegraphics[interpolate]{image-a.png}
\includegraphics{image-a.pdf}
\includegraphics[interpolate]{image-a.pdf}
\end{document} 

enter image description here