# LaTeX Photo With Rounded Corners

I have a photograph that I'm loading into my LaTeX document.

I'd like the photograph to have rounded corners and no visible border.

I'd prefer not to edit the original photograph.

Any thoughts on how to do this?

• Nov 22, 2014 at 19:40

## 5 Answers

Another possibility if you want to fix the dimensions of the pictures :

\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}

\begin{document}
\begin{tikzpicture}

\begin{scope}
\clip [rounded corners=.5cm] (0,0) rectangle coordinate (centerpoint) (5,7.5cm);
\node [inner sep=0pt] at (centerpoint) {\includegraphics[width=6.0cm]{EiffelTall.jpg}};
\end{scope}

\begin{scope}[xshift=7cm]
\clip [rounded corners=.5cm] (0,0) rectangle coordinate (centerpoint) ++(5cm,7.5cm);
\node [inner sep=0pt] at (centerpoint) {\includegraphics[width=10.0cm]{EiffelTall.jpg}};
\end{scope}

\end{tikzpicture}
\end{document}


• Could you please explain why ++ works or is needed in the second example? I am trying to gain a solid understanding by grasping your answer along with Paul Gaborit's answer here: tex.stackexchange.com/a/76216/13552 These methods are much better than "the white box" methods because they don't require a white background. Feb 3, 2016 at 13:42
• @macmadness86 You can remove ++ . It's not necessary Feb 4, 2016 at 15:19

One way would be to use tikz to create a node with the image, and draw a rectangle with rounded corners using white color to clip the image. Here is the original image and one with the white rectangle drawn over it:

## Notes:

• The value of \ClipSep defined the amount of clipping so this can be adjusted as desired.

## Code:

\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}

\newcommand*{\ClipSep}{0.4cm}%

\begin{document}
\includegraphics[width=5.0cm]{images/EiffelTall.jpg}
%
\begin{tikzpicture}
\node [inner sep=0pt] at (0,0) {\includegraphics[width=5.0cm]{images/EiffelTall.jpg}};
\draw [white, rounded corners=\ClipSep, line width=\ClipSep]
(current bounding box.north west) --
(current bounding box.north east) --
(current bounding box.south east) --
(current bounding box.south west) -- cycle
;
\end{tikzpicture}
\end{document}

• If you'd want to put this image with rounded corners in a fixed width environment (at the margin, for example), and so the effective image width was exactly \linewidth... how could that be achieved? I mean, with your code the image width is the actual original width plus the one of the white tikz rectangle. Nov 21, 2014 at 21:43
• @PabloB.: Not sure I fully understand, but I think what you want is \noindent before the \begin{tikzpicture}, and use \includegraphics[width=\linewidth,keepaspectratio]. If that does not solve your issue, I would suggest you post a new question with a MWE including \documentclass and the appropriate packages that sets up the problem. Nov 21, 2014 at 21:47
• The thing is that the white rectangle adds extra width to the original image, so in order to get the real width, you'd need to do something similar to \includegraphics[width=\myfactor*\linewidth,keepaspectratio] notice myfactor correction. Should I post a new question? Nov 21, 2014 at 21:57
• @PabloB.: Yes you should post a new question as it is really not related to rounded corners. Nov 21, 2014 at 23:26

I borrowed an image from Herbert's answer without his permission.

User defined data:

\def\M{3}% columns
\def\N{3}% rows
\def\scale{1}% scale
\def\filename{herbert}% filename

% Specify the cropping area.
\def\L{-2}
\def\B{-1.5}
\def\R{2}
\def\T{3}


Steps:

1. Specify the number of columns and rows. The greater values, the more accurate coordinates. Avoid changing these values after completing the 3rd step, unless you are happy to redo the 3rd step.
2. Specify the scaling factor. It does not depend on other steps.
3. Specify the cropping area. You might need a trial and error approach to find it.
4. Compile the following code with either xelatex or latex-dvips-ps2pdf. See the result, if the cropping region does not suit your requirement, do the 3rd and 4th again.

Hopefully, the given comments in the code are self-explanatory.

\documentclass[pstricks,border=12pt]{standalone}

\def\M{3}% columns
\def\N{3}% rows
\def\scale{1}% scale
\def\filename{herbert}% filename

\usepackage{graphicx}
\newsavebox\IBox
\savebox\IBox{\includegraphics[scale=\scale]{\filename}}

\usepackage{pstricks}
\psset
{
xunit=0.5\dimexpr\wd\IBox/\M\relax,
yunit=0.5\dimexpr\ht\IBox/\N\relax,
}

\begin{document}

% The following figure shows an image with a grid enabled.
% Use the grid to find the cropping area.
\begin{pspicture}[showgrid=true](-\M,-\N)(\M,\N)
\rput(0,0){\usebox\IBox}
\end{pspicture}

% Specify the cropping area.

\def\L{-2}
\def\B{-1.5}
\def\R{2}
\def\T{3}

\begin{pspicture}[showgrid=false](\L,\B)(\R,\T)
\begin{psclip}{\psframe[linestyle=none,framearc=0.5,dimen=middle](\L,\B)(\R,\T)}
\rput(0,0){\usebox\IBox}
\end{psclip}
\end{pspicture}
\end{document}


## Output:

Original image with a grid.

Cropped image.

I'm surprised that nobody presented the solution of tikz, but when you don't know the size of the node. The idea is to print it one using phantom to get the size, and then use the tikz clip function.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{graphicx}

\newcommand*{\bord}{1mm}
\begin{document}
\begin{tikzpicture}
\def\ig{%
\includegraphics[width=7cm,height=7cm,keepaspectratio]{example-image-10x16}}
\node [inner sep=0pt](mypicture) at (0,0) {\phantom{\ig}};
\clip[rounded corners=5mm] ($(mypicture.south west)+(\bord,\bord)$) rectangle ($(mypicture.north east)-(\bord,\bord)$);
\node[inner sep=0pt](mypicture) at (0,0) {\ig};
\end{tikzpicture}
\end{document}


file:///tmp/Spectacle.f17590.png

• Works nicely and a rounded frame can be added easily with: \draw[gray, rounded corners=5mm, line width=2pt] ($(mypicture.south west)+(\bord,\bord)$) rectangle ($(mypicture.north east)-(\bord,\bord)$); right before \end{tikzpicture} Apr 29, 2018 at 20:58
• Great solution! Would you mind updating the answer to describe \bord ? I'm using this solution without it. Jun 15 at 19:02
• @ɲeuroburɳ \bord is just a shortcut for 1mm that I defined above: \newcommand*{\bord}{1mm}. I use it to avoid changing 1mm in multiple places (another option is to write directly a macro for that) Jun 16 at 11:34

If you just want round corners there are an easy solution: just use GIMP. Take your picture, go on filter -> decoration -> round corners and there you can make round corners and put a shadow beneath and a lot more.

I know it is not a really "LaTeX-solution", but it is the most easy thing to do. If you need to use Tikz everytime you will make round corners, it would take a lot of time. Especially if you use other commands on the picture already (minipage and so on). You can save a lot of time with using such simple methods as GIMP - so you can use it on more LaTeXic things.