How to avoid visual artifacts between fbox and graphics?

I'd like a simple black border around my images:

\documentclass{article}
\usepackage{graphicx}
\usepackage{calc}
\usepackage{mwe}
\setlength{\parindent}{0pt}
\setlength{\fboxsep}{0pt}
\begin{document}
\includegraphics[width=\linewidth]{example-image}\\
\fbox{\includegraphics[width=\linewidth - 2\fboxrule - 2\fboxsep]{example-image}}
\end{document}


This is working fine, except when zooming in. In the bottom image, you see a faint line between the image and the border:

I see this in a number of PDF viewer (Acrobat Reader on Windows, Google Chrome on Windows, pdf.js on Linux). I had though that I could solve this using a black background within the border, but I see the same artifacts:

\documentclass{article}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{calc}
\usepackage{mwe}
\setlength{\parindent}{0pt}
\setlength{\fboxsep}{0pt}
\begin{document}
\includegraphics[width=\linewidth]{example-image}\\
\fcolorbox{black}{black}{\includegraphics[width=\linewidth - 2\fboxrule - 2\fboxsep]{example-image}}
\end{document}


Can I avoid this?

You could avoid drawing a frame and just draw a single rule behind the image, either directly with \rule or using \colorbox as here

\documentclass{article}
\usepackage{graphicx}
\usepackage{xcolor}

\setlength{\parindent}{0pt}
\setlength{\parskip}{20pt}

\begin{document}
\includegraphics[width=\linewidth]{example-image}

{
\setlength{\fboxsep}{0pt}

\fcolorbox{black}{black}{\includegraphics[width=\dimexpr\linewidth - 2\fboxrule - 2\fboxsep]{example-image}}

}

{
\setlength{\fboxsep}{2pt}

\colorbox{black}{\includegraphics[width=\dimexpr\linewidth - 2\fboxsep]{example-image}}

}

\end{document}