7

I am trying to crop a picture so that it is shaped like a circle and additionally put a border around it. So far I figured out I will crop an image so that it looks like circle by using \clip:

\documentclass[12pt]{article}
\usepackage{tikz}
 \begin{document}
 \begin{tikzpicture}
      \begin{scope}
        \clip [rounded corners=.6cm] (0,0) rectangle coordinate (centerpoint) (1.2,1.2cm);
        \node [inner sep=0pt] at (centerpoint) {\includegraphics[width=1.2cm, height=1.2cm]{example-image-b}};
      \end{scope}
    \end{tikzpicture}
\end{document}

Effect:

circled image

How do I make a red-colored border (circle-shaped) around the picture?

I thought about painting one image on top of another, but the circle and the image get arranged side by side. I am a beginner so any clue will be appreciated.

11

You can use a circle outside of the clipped scope. If the line interferes with your picture you might want to increase the radius a bit (the second part of the draw circle command).

circle

\documentclass[12pt]{article}
\usepackage{tikz}
 \begin{document}
 \begin{tikzpicture}
      \begin{scope}
        \clip [rounded corners=.6cm] (0,0) rectangle coordinate (centerpoint) (1.2,1.2cm);
        \node [inner sep=0pt] at (centerpoint) {\includegraphics[width=1.2cm, height=1.2cm]{example-image-b}};
      \end{scope}
      \draw[red] (.6cm,.6cm) circle (.6cm);
    \end{tikzpicture}
\end{document}
| improve this answer | |
3

I intentionally provide you with a more general solution because a circle can easily be obtained from an ellipse. This solution is written with PSTricks and must be compiled with either xelatex or latex-dvips-ps2pdf sequence.

\documentclass[pstricks]{standalone}
\usepackage{graphicx}
\newsavebox\temp
\savebox\temp{\includegraphics[scale=1]{example-image-a}}
\def\N{5}
\psset
{
    xunit=.5\dimexpr\wd\temp/\N\relax,
    yunit=.5\dimexpr\ht\temp/\N\relax,
}
\begin{document}
\begin{pspicture}[linewidth=2pt,linecolor=red](-\N,-\N)(\N,\N)
\psclip{\psellipse(\N,\N)}
    \rput(0,0){\usebox\temp}
\endpsclip
\psellipse(\N,\N)
\end{pspicture}
\end{document}

enter image description here

| improve this answer | |
2

The skins option of tcolorbox simplify a lot this task:

\documentclass{article}
\usepackage[skins]{tcolorbox}
\begin{document}
\begin{tikzpicture}

  \node[circle,draw, very thick, color=red, minimum size=5cm, 
        fill overzoom image=example-image]{};

\end{tikzpicture}
\end{document}

mwe

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.