3D image stack with tikz

Here is an example that defines a new \imagestack command. The stack is created by drawing the frames in the background on a background layer.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
    \begin{tikzpicture}
    \pgfdeclarelayer{bg}    
    % set the order of the layers (main is the standard layer)  
    \pgfsetlayers{bg,main}  
    % \imagestack{image_name}{position}{path_to_image}
    \newcommand{\imagestack}[3] {   
        \node[inner sep=0, draw] (#1) at (#2) {\includegraphics[width = 2cm]{#3}};
        \coordinate (offset) at (0.05cm, 0.05cm);
        % draw on the background layer
        \begin{pgfonlayer}{bg}    
            \foreach \i in {3,...,1}
            \filldraw[draw=black, fill=white] ($(#1.south east) + \i*(offset)$) rectangle ($(#1.north west) + \i*(offset)$);
        \end{pgfonlayer}
    }
    \imagestack{image}{{0,0}}{example-image-a}
    \end{tikzpicture}
\end{document}

enter image description here

Tags:

Tikz Pgf