Overlay image with parts of another image
To expand on Ulrike's comment, here is a quick and dirty example on how to clip an external image that is directly taken from the pgf manual
\documentclass[12pt,a4paper]{article}
\usepackage{graphicx,tikz}
\begin{document}
\begin{tikzpicture}[path image/.style={
path picture={
\node at (path picture bounding box.center) {
\includegraphics[height=3cm]{#1}
};}}]
\draw [path image=example-image-b,thick](0,1) -- (0,3) -- (1.5, 1.5) -- (1,1) -- cycle;
\end{tikzpicture}
\end{document}
Then you can superimpose two images, once having clipped one.
Another solution clipping images included as nodes:
\documentclass[tikz,border=2mm]{standalone}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\path[clip] (0,0)--++(0:3.5cm)--++(75:3cm)-|cycle;
\node[anchor=south west] {\includegraphics[width=6cm]{Q7xB7}};
\end{scope}
\begin{scope}
\path[clip] (6,0)--++(180:2.3cm)--++(75:3cm)-|cycle;
\node[anchor=south east] at (6,0) {\includegraphics[height=3cm]{8pyV9}};
\end{scope}
\end{tikzpicture}
\end{document}
Update
If you want to cover some part of the page with this picture, it's better to use absolut positioning, which can be done with remember picture
and overlay
options and using the current page
node. You need to compile twice before getting the correct result.
The white space around the figure was due to inner sep
which keeps a certain distance between node contents and border. With inner sep=0pt
, there is no space.
Finally you can use bb
("bounding box") option from graphicx
package to select which part of the included figure is shown: bb=0 0 1400 702
means take the rectangle from (0,0) to (1400,702) points (Postscript points not pixels). I think you'll have to test to find the desired fragment.
\documentclass{article}
\usepackage{tikz}
\usepackage[b5paper, lmargin=25mm, rmargin=25mm, tmargin=27mm, bmargin=30mm]{geometry}
%\usepackage{graphics,graphicx,calc}
\usepackage{calc}
\definecolor{main}{HTML}{003349}
\pagestyle{empty}
\def\mygraphic{\includegraphics[width=\paperwidth]{Q7xB7.png}}
\newlength\graphicheight
\setlength\graphicheight{\heightof{\mygraphic}}
\begin{document}
\begin{tikzpicture}[overlay, remember picture]
%
\begin{scope}
\path[clip] (current page.south west)--++(0:10.8cm)--++(70:\graphicheight)-|cycle;
\node[anchor=south west, inner sep=0pt] at (current page.south west) {\mygraphic};
\end{scope}%
\begin{scope}
\path[clip] (current page.south east)--++(180:6.7cm)--++(70:\graphicheight)-|cycle;
\node[anchor=south east, inner sep=0pt] at (current page.south east) {\includegraphics[height=\graphicheight, bb=0 0 1400 702, clip]{8pyV9}};
\end{scope}
\end{tikzpicture}
\end{document}
This is very similar to the other two answers with the main difference being that I install a local coordinate system on the pic to make things more convenient. You still need to find out the coordinates by looking, but now the clip path becomes
\clip (0.6345,0) -- (0.963,1) -| (1,0) -- cycle;
where the coordinates are such that (0,0)
is the lower left and (1,1)
the upper right corner of the "reference" picture. This way you do not have to put in explicit dimensions.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage[b5paper,lmargin=25mm, rmargin=25mm,tmargin=27mm, bmargin=30mm]{geometry}
\begin{document}
\begin{tikzpicture}[nodes={inner sep=0pt,anchor=south west}]
\node (X) {\includegraphics[width=\textwidth]{picA}};
\begin{scope}[x={(X.south east)},y={(X.north west)}]
\begin{scope}
\clip (0.6345,0) -- (0.963,1) -| (1,0) -- cycle;
\path let \p1=(X.north east) in (0,0)
node{\includegraphics[width=\x1,height=\y1]{picB}};
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}