I would like to make visibly clear, that an inserted graphic is just part of the whole. Since a straight cut just appears as inserted falsy, I was wondering if there are any tricks to show jags for the trimmed sides. Something like this for instance:
Asked
Active
Viewed 580 times
8
-
lpic package may help you – touhami Mar 25 '16 at 15:51
-
related http://tex.stackexchange.com/questions/9559/drawing-on-an-image-with-tikz – touhami Mar 25 '16 at 16:11
1 Answers
15
You can use decorations in TikZ to morph a path using random steps. Of course, you can customize these random steps.
I used a \clip with hard-coded coordinates starting from the top left of the image, then top right, down to about 2/3 then left again before closing the path. If you change the width of the includegraphics, make sure to change the clipping coordinates accordingly.
Although this can be solved easily using variables.
Output

Code
\documentclass[margin=15pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, decorations.pathmorphing}
\newcommand\myimgwidth{\linewidth} % one measure to rule them all
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro\myheight{(\myimgwidth/4)*2}
\clip[preaction={draw, line width=.8pt}] (0,0) -- (\myimgwidth,0) -- (\myimgwidth,-\myheight pt) decorate[decoration={random steps,segment length=2mm,amplitude=.1cm}] {(\myimgwidth,-\myheight pt) -- (0,-\myheight pt)} -- (0,0);
\node[inner sep=0pt, outer sep=0pt, anchor=north west] at (0,0) {\includegraphics[width=\myimgwidth,keepaspectratio]{example-image-a}};
\end{tikzpicture}
\end{document}
Alenanno
- 37,338
-
This seems to be a great solution. Would you mind to show quickly how to apply this
TikZeffect on a includegraphic? – Eric Mar 25 '16 at 16:36 -
@Eric This effect was applied on an includegraphics from the start. I only edited it because the randomized line was not horizontal. :D – Alenanno Mar 25 '16 at 16:37
-
I have some tricky effects of resolution --- namely, sometime half of the border line of the graphics appears. Changing
\filltodraw[red, fill=white]I have this: http://i.imgur.com/QIi04xU.png (viewer dependent, but also probably printer dependent...) – Rmano Mar 25 '16 at 17:21 -
@Rmano That's not a tricky effect, that's the rectangle I have drawn on top of the graphics that is filled with white. I'll find a solution to draw only the decoration. – Alenanno Mar 25 '16 at 17:28
-
@Alenanno yep, I know, the problem is the small vertical gray line which (I think) is a remnant of the underlying image --- there is a problem of resolution in the viewer that makes it show up. – Rmano Mar 25 '16 at 17:43
-
@Alenanno yes this is awesome! I would like to stretch the pic to
\linewith. But the "frame" sticks. Is there a way to fix this also?:)– Eric Mar 25 '16 at 18:56 -
it doesn't expand on
\linewidth. I am not good atTikZ, but maybe it sticks on 8 cm? I added the code to my question – Eric Mar 25 '16 at 18:59 -
@Eric Of course you need to change
8to\linewidthin the coordinates. Also, you should remove the code from the question because it wasn't originally there (and it might confuse the readers). :P I'll let you know if I find a better way to do that. – Alenanno Mar 25 '16 at 19:05 -
1@Eric See new edit. If using this in an
articleclass gives you an overfull \hbox I suggest reducing the width. – Alenanno Mar 25 '16 at 19:11 -
it is nested in a minipage anyway. But this is quite a decent solution! Thanks so much for your help!!! – Eric Mar 25 '16 at 19:13
-
Idk what you intended this for, but I removed the multiply 2, because this increased the space for my height too much. (
\pgfmathsetmacro\myheight{(\myimgwidth/4)*2}) – Eric Mar 25 '16 at 19:19 -
@Eric The space? Which space? I suppose you could leave
\pgfmathsetmacro\myheight{\myimgwidth/2}and the result would be similar but better. – Alenanno Mar 25 '16 at 20:29 -
@Alenanno There is a bit whitespace inbetween the end of the picture and the begin of the jags. When I use
\pgfmathsetmacro\myheight{\myimgwidth/2}this space is massive. Currently I am using /5 which is pretty good. And regarding the overfull box, .999\linewidth in the preamble can fix it already – Eric Mar 25 '16 at 20:33
