Crop jpeg into circular tikz node
You can use path picture
key.
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\tikz\node[circle,draw,
text=white,
path picture={
\node at (path picture bounding box.center){
\includegraphics[width=3.5cm]{frog}
};
}]{I'm watching you!};
\end{document}
Image is writelatex's frog.jpg
Here is another frog solution which also uses path picture
beneath. If you don't mind loading tcolorbox
for this purpose, you can use its fill overzoom image
option for TikZ. This option takes a picture file name as parameter (here frog.jpg
again) and scales this image to fit into (or better: over) the shape:
\documentclass[border=5mm]{standalone}
\usepackage[skins]{tcolorbox}
\begin{document}
\begin{tikzpicture}
% one picture
\node[circle,draw,inner sep=2cm,fill overzoom image=frog] (A) {};
% some more
\foreach \w in {1,2,...,6}
{
\path (A) (\the\numexpr\w*60\relax:\the\numexpr 3+\w/2\relax cm)
node[circle,draw,inner sep=\the\numexpr\w*2\relax mm,fill overzoom image=frog] (B) {};
\draw[very thick,red,->] (A)--(B);
}
\end{tikzpicture}
\end{document}
As a bonus, here are some more frogs put into different shapes (zoomed automatically):
\documentclass[border=5mm]{standalone}
\usepackage[skins]{tcolorbox}
\begin{document}
\begin{tikzpicture}[radius=1cm,delta angle=180]
\path[draw,thick,fill overzoom image=frog]
(0,0) arc [start angle=-90] -- ++(-2,0) arc [start angle=90] -- cycle;
\path[draw,thick,fill overzoom image=frog]
(3.5,2) arc [start angle=0] -- ++(0,-2) arc [start angle=180] -- cycle;
\end{tikzpicture}
\end{document}
And, finally, just one frog which fills a path consisting of two separate parts:
\documentclass[border=5mm]{standalone}
\usepackage[skins]{tcolorbox}
\begin{document}
\begin{tikzpicture}[radius=1cm,delta angle=180]
\path[draw,thick,fill overzoom image=frog]
(0,4) arc [start angle=-90] -- ++(-2,0) arc [start angle=90] -- cycle
(3.5,6) arc [start angle=0] -- ++(0,-2) arc [start angle=180] -- cycle;
\end{tikzpicture}
\end{document}
Since I could not find writelatex's frog.jpg
, I'm using the Masked tree frog head
from Charlesjsharp on Wikimedia, which is 851x567 px big.
I like to use clip
, since one can then clip the image with lots of different shapes. In this case I clip the image with a circle of half the radius of the shorter length of the image, centered onto the middle of the image.
\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\newcommand{\imsize}{\linewidth}
\newlength\imagewidth
\newlength\imagescale
\begin{document}
\renewcommand{\imsize}{0.618\linewidth}
\pgfmathsetlength{\imagewidth}{\textwidth}%
\pgfmathsetlength{\imagescale}{\imagewidth/851}%
\begin{tikzpicture}[x=\imagescale,y=-\imagescale]
\clip (851/2, 567/2) circle (567/2);
\node[anchor=north west, inner sep=0pt, outer sep=0pt] at (0,0) {\includegraphics[width=\imagewidth]{Masked_tree_frog_head}};
\end{tikzpicture}
\end{document}