1

I am trying to remove parts of my image so it looks like it is inside of a shape (tikzpicture). I don't have an idea how to do it, I guess that my LaTeX code (see below) has to be thought over.

This is my output right now: enter image description here And this is how it should look like: enter image description here This is my LaTeX Code:

\documentclass[a4paper,12pt,oneside]{scrreprt}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{graphicx}

\begin{document}

\clearpage
\vspace*{-2.5cm}

\begin{tikzpicture}[remember picture,overlay]
\fill[color = red] (-3.5cm, -0.5cm) node{}
-- (-3cm,-5cm) node{}
-- (\paperwidth,-6cm) node{}
-- (\paperwidth,0.5cm) node{};
\end{tikzpicture}

\begin{minipage}[ht]{0.28\textwidth}
    \begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.29\paperwidth]{Test}};
    \end{tikzpicture}
\end{minipage}

\end{document}

Thanks in advance for any help!

owmal
  • 325
  • 1
    Now if you really want to be fancy, store the coordinates of the corners and use a graphics editor (like Gimp) to apply a perspective transformation. See https://tex.stackexchange.com/questions/312238/how-to-create-a-tikz-picture-with-a-non-infinite-distance-viewpoint/312959?r=SearchResults&s=1|21.9088#312959 – John Kormylo Apr 26 '20 at 17:43
  • The perspective solution is interesting. Thanks for your comment, John! – owmal Apr 26 '20 at 19:12
  • Please don't answer in the question, add a new answer – CarLaTeX Apr 27 '20 at 16:12
  • Thank you for your note! I now posted it as a new answer. – owmal Apr 28 '20 at 15:44

2 Answers2

5

Here is a working example of what you could do with a clip and a preaction to fill the clipped area

\documentclass[tikz]{standalone}
\usepackage{xcolor}
\usepackage{graphicx}

\begin{document}
    % Without clip
    \begin{tikzpicture}
        \path[preaction={fill=red}] (0,-2) -- (5,-4) -- (5,4) -- (0,2) -- cycle;
    \node[inner sep=0] (image) at (2,0) {\includegraphics[scale=0.75]{example-image-a}};
    \end{tikzpicture}
    % With clip
    \begin{tikzpicture}
        \path[clip,preaction={fill=red}] (0,-2) -- (5,-4) -- (5,4) -- (0,2) -- cycle;
    \node[inner sep=0] (image) at (2,0) {\includegraphics[scale=0.75]{example-image-a}};
    \end{tikzpicture}

\end{document}

Without clip

enter image description here

With clip

enter image description here

BambOo
  • 8,801
  • 2
  • 20
  • 47
0

Update: based on BambOo's answer, I've updated the code above to be suited for my example. It looks just like what I've wanted to create. Here is the new code, if that helps anyone:

\documentclass[a4paper,12pt,oneside]{scrreprt}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{graphicx}

\begin{document}

\clearpage
\vspace*{-2.5cm}

\hspace*{-3.5cm}\begin{tikzpicture}
\path[clip,preaction={fill=red}] (-3.5,-0.5) -- (-3.5,-5) -- (\paperwidth,-6) -- (\paperwidth,0.5) -- cycle;
\node[inner sep=0] (image) at (3,-3) {\includegraphics[scale=0.65]{Test}};
\end{tikzpicture}

\end{document}

It looks almost like this

owmal
  • 325