# Watermark on pictures only

I know how to use a watermark on a full page in LaTeX reports, using for instance this code:

\usepackage{draftwatermark}
\SetWatermarkText{Confidential}
\SetWatermarkScale{5}


However, on my report, I would like to use watermark only on the pictures/graphics I included, so that the text is not hidden by anything. Only the pictures shall be marked with e.g. "Confidential".

-

Try xwatermark package. It allows you to specify the positions (on the page) of the watermarks - for graphics and text.

\documentclass{article}
\makeatletter
\usepackage[dvipsnames]{xcolor}
\usepackage[printwatermark]{xwatermark}
\thispagestyle{empty}

% Local watermark locations:
\watermarkpaths{{./}{./Graphics/}}

% One combined watermark (graphics + text). This is what you need. The key
% to note here is 'textontoppic':
\newwatermark[
oddpages,coordunit=pc,fontfamily=put,textcolor=red,
fontsize=2cm,textalign=center,textangle=29,picangle=0,
textxpos=-1,textypos=1,picxpos=0,picypos=0,
textontoppic,picbb=20 21 590 400,
picscale=.6,picfile=comet1,picfileext=pdf
]{Confidential}

% Repeated combined watermark (graphics + text):
\xwmgetpicturesize[scale=.5,viewport=20 21 590 400]{comet1}
\def\twidth#1{.5\paperwidth#1\widthofpic}
\def\theight#1{.5\paperheight#1\heightofpic}
\repeatwatermarks[Page=\thepage]{%
oddpages,coordunit=pc,picbb=20 21 590 400,picscale=.5,picfile=comet1,
textontoppic,fontsize=2.5cm,textcolor=white
}{%
picxpos=-\twidth{+}/2,picypos=-\theight{+}/2,
textxpos=-\twidth{+}/2,textypos=-\theight{+}/2;
picxpos=-\twidth{+}/2,picypos=\theight{-}/2,
textxpos=-\twidth{+}/2,textypos=\theight{-}/4;
picxpos=\twidth{-}/2,picypos=-\theight{+}/2,
textxpos=\twidth{-}/2,textypos=-\theight{+}/2;
picxpos=\twidth{-}/2,picypos=\theight{-}/2,
textxpos=\twidth{-}/2,textypos=\theight{-}/4
}
\makeatother

\begin{document}
xx
\end{document}
\newpage
yy
\newpage
zz
\newpage
aa
\newpage
bb
\end{document}


-

Grabbing some code from Resize large images that exceed page margin whilst respecting existing scale, a redefinition of \includegraphics can place a "confidentiality notice" over all images, or selectively exclude the notice:

\documentclass{article}
\usepackage{xparse,graphicx,xcolor}% http://ctan.org/pkg/{graphicx,xcolor}
\newcommand{\confidential}{\color{red!80}\LARGE\bfseries CONFIDENTIAL}% Confidentiality notice
\newsavebox\IBox
\let\IncludeGraphics\includegraphics
\RenewDocumentCommand{\includegraphics}{s O{} m}{%
\sbox\IBox{\IncludeGraphics[#2]{#3}}%
\ooalign{\usebox\IBox% Print graphic
\IfBooleanTF{#1}{}{% Confidential or not
\cr\hss%
\raisebox{.1\ht\IBox}{\resizebox{.8\wd\IBox}{.8\ht\IBox}{\confidential}}% Print confidentiality notice
\hss}}}%
\begin{document}
\includegraphics[width=20pt]{example-image-a}
\includegraphics[height=30pt]{example-image-b}
\includegraphics[width=10em,height=10em]{example-image-c}
\includegraphics*[scale=.2]{example-image-a}
\renewcommand{\confidential}{\color{green!70}\rule{10pt}{10pt}}% Change confidentiality notice
\includegraphics[width=15ex]{example-image-b}
\end{document}


xparse provides the interface for the modified version of \includegraphics. It now provides a starred variant \includegraphics* that prints an image without a "confidentiality notice".

The "confidentiality notice" is centred and stretched to fit over 80% of the image height/width.

-