Getting ducks in example images

Write a document example-duck:

\documentclass[tikz,multi]{standalone}
\usepackage{tikzducks}
\begin{document}
\foreach\x in {1,2,...,100}
{\tikz\randuck;}
\end{document}

and compile it.

Then you can use it like this:

\documentclass{article}
\usepackage{xfp,graphicx}
\newcommand\getduck{\fpeval{randint(1,100)}}

\begin{document}

\includegraphics[page=\getduck]{example-duck}

\includegraphics[page=\getduck]{example-duck}

\includegraphics[page=\getduck]{example-duck}

\end{document}

enter image description here or enter image description here

Edit

as requested in the comments here a more refined example-duck (the pointy head of the witch needs a rather large background):

\documentclass[tikz,multi]{standalone}
\usepackage{tikzducks}
\begin{document}
\foreach\x in {1,2,...,100}
{\begin{tikzpicture}
 \draw[fill=gray!50!white](-0.8,-0.8)rectangle(3,3);
 \draw[gray] (-0.8,-0.8)--(3,3)
             (3,-0.8)--(-0.8,3)
             (-0.8,1.1)--++(3.8,0)
             (1.1,-0.8)--++(0,3.8)
             ;
 \randuck;
 \node [anchor=center,rounded corners,draw=darkgray,opacity=0.5,fill=lightgray,rotate=30,font=\sffamily] at (1.1,1.1) {example duck};
 \end{tikzpicture}}
\end{document}

enter image description here


The following could be used:

\documentclass[]{article}

\usepackage{tikzducks}
\usepackage{adjustbox}

\newcommand\exampleDuck[1][]
  {%
    \adjustbox{#1}{%
      \begin{tikzpicture}
        \draw[black,fill=gray!50,thick] (0,0) rectangle (6,4);
        \draw[gray] (0,0) -- (6,4);
        \draw[gray] (0,4) -- (6,0);
        \draw[gray] (3,0) -- (3,4);
        \draw[gray] (0,2) -- (6,2);
        \node at (3,2) {\tikz\randuck;};
      \end{tikzpicture}
    }%
  }

\begin{document}
\exampleDuck[width=2cm]

\exampleDuck[height=5cm]

\exampleDuck
\end{document}

enter image description here

With this package you can also use the following (also on github):

\documentclass[]{article}

\usepackage{graphicx}
\usepackage{duckuments}

\begin{document}
\noindent
\includegraphics[width=.5\textwidth]{example-image-duck}% takes a random page from the pdf
\includegraphics[width=.5\textwidth]{example-image-a}% still working

\blindduck% print one paragraph of text

\duckument% print a small duckument

\end{document}

Result: enter image description here