# Disable anti-aliasing in ps2pdf

I have generated the EPS files my self. In the EPS files, I have set the \interpolate false option. I include them in the LaTeX source with includegraphics within TikZ (because I want several of them positioned nicely close to each other.)

Then I run the standard set of steps:

latex src.tex
dvips -Ppdf src.dvi
ps2pdf src.ps


In a text editor, I see that the PostScript source file, has preserved the full EPS file text. Even my comments in it (as it should). So the \interpolate false line has also remained. When I open the PostScript source with Evince (the GNOME pdf viewer), indeed there is no interpolation. Just for a check, with the editor I set \interpolate true and re-opened the PostScript file and confirmed that indeed now Evince interpolates the image. This shows that atleast Evince understands this option.

But when I open the src.pdf file that was output from ps2pdf. I see that the output is interpolated (anti-aliased) in any case! I also opened the PDF file with a text editor and found that only the most basic parameters of the EPS image have remained (like width or height). \interpolate false had been removed.

From the results above, I see that the problem is not in includegraphics or any of the LaTeX steps or even my pdf viewer. It is in ps2pdf.

In its documentation, it seems to have AntiAliasColorImages, AntiAliasGrayImages and AntiAliasMonoImages, but then in the following it says:

(note 0) This parameter can be set and queried, but currently has no effect.


So when I run the following command, there is no difference:

ps2pdf -dAntiAliasGrayImages=false -dAntiAliasMonoImages=false src.ps


I wanted to see if there is any way I can solve the issue. It is very important for me that anti-aliasing does not occur in the PDF file.

• This seems to me to be off-topic, but I'm not sure. It doesn't really have anything to do with TeX, as you say. ps2pdf is part of ghostscript. Basically, it sounds in any case as though this is just a known limitation of the software. You could file a feature request, but I can't think of much else you can do unless you want to work on a patch yourself. – cfr Apr 26 '15 at 4:04
• You are right! The reason I posted it here was this answer: tex.stackexchange.com/questions/10975/… . It claims that the problem lies in the PDF viewer. But the case above shows that it doesn't. Am I correct? I was assuming people who use TeX also use ps2pdf a lot also and must have experience in it. – makhlaghi Apr 26 '15 at 4:09
• I thought that maybe adding a /interpolate false line in the PDF file might fix the problem. So I asked this question in stackoverflow: stackoverflow.com/questions/29873726/… . I will also try to contact the Ghostscript maintainers and suggest a feature request. – makhlaghi Apr 26 '15 at 4:29

The default value for the key /Interpolate in the image dictionary of the PDF file is false, see PDF specification, section 8.9.5.3 Image Interpolation. Therefore adding /Interpolate false only makes the default explicit. Likely, the anti-aliasing is done by the PDF viewer and it should be turned off there.

Notice also the note that comes with the description for /Interpolate:

A conforming Reader may choose to not implement this feature of PDF, or may use any specific implementation of interpolation that it wishes.

## Test of /Interpolate

The driver pdftex.def for package graphics supports the boolean key interpolate, which maps its setting to the key /Interpolate in the image dictionary. The default (false) and the enabled key show the expected results with this image in AR9 or xpdf 3.03 or evince 3.4.0:

\documentclass{article}
\pagestyle{empty}
\usepackage{graphicx}
\begin{document}
\centering
\includegraphics[width=.48\linewidth]{uJ9k7.png}\hfill
\includegraphics[width=.48\linewidth, interpolate]{uJ9k7.png}
\end{document}


• Thanks for the complete answer. It seems to work for pdflatex and PNG. But when I apply it to a similar EPS file (with latex), it says: ! Package keyval Error: interpolate undefined. refereing the second last line in the MWE. But this is another issue and your answer clearly resolved my question. Thank you. – makhlaghi Apr 26 '15 at 6:11
• @makhlaghi dvips does not support such a key, the \special, which is written to the PDF file does not support keys for additional features like interpolate. – Heiko Oberdiek Apr 26 '15 at 6:43