How to replace the rectangular photo in moderncv (classic style) with a round photo

moderncv

How can I replace the rectangular photo / picture in moderncv, classic style, with a round one?

MWE:

\documentclass[11pt,a4paper,sans]{moderncv} 
\moderncvstyle{classic}

\name{John}{Doe}
\address{Don Knuth Street, 42}{Tex City}
\photo[100pt][0pt]{pictures/picture.jpg}

\begin{document}
\makecvtitle
\end{document}

Output:

enter image description here

@Ingmar: Thanks a lot for your reply! I tried your solution in your answer, but the photo is not in the right position. In addition, this solution works only with \documentclass[...]{moderncv} and not \documentclass[...]{standalone}. Do you know how to fix this and put the photo in the correct position as in the default moderncv style?

\documentclass[11pt,a4paper,sans]{moderncv} 
\moderncvstyle{classic}

%% Ingmar solution
\usepackage{tikz,graphicx}

\name{John}{Doe}
\address{Don Knuth Street, 42}{Tex City}
%% Ingmar solution
% \photo[100pt][0pt]{pictures/picture.jpg}

\begin{document}
\makecvtitle
%% Ingmar solution
\begin{tikzpicture}
  \clip (0,0) circle (1);
  \node[inner sep=0pt]  at (0,0) 
{\includegraphics{pictures/picture.jpg}};
\end{tikzpicture}
\end{document}

enter image description here

Best Answer

Try this code. No additional packages are required.

\documentclass[11pt,a4paper,sans]{moderncv} 
\moderncvstyle{classic}

\name{John}{Doe}
\address{Don Knuth Street, 42}{Tex City}
\photo[200pt][0pt]{example-image} % <<<<<<<<<<<<< set width 

%************************************** added <<<<<<<<<<<<<<<   
\makeatletter
\usepackage{xpatch}
\xpatchcmd{\makecvhead}
{\includegraphics[width=\@photowidth]{\@photo}}
{\begin{tikzpicture}\clip (0,0) circle (2cm);\node at (0,0) {\includegraphics[width=\@photowidth]{\@photo}};\end{tikzpicture}}
{}{}
\makeatother
%************************************** 

\begin{document}    
    \makecvtitle
\end{document}

The circle has a radius of 2 cm. You need to set the width of the photo (200pt in this example) so that no border falls inside the circle.

Usage: \photo[<picture width>][0pt]{<picture filename>}

b

UPDATE after follow-up question: move the picture

Use:

\newcommand{\yshift}{<length>}  % down if negative

\newcommand{\xshift}{<length>}  % right if positive

z

This is the updated code.

\documentclass[11pt,a4paper,sans]{moderncv} 
\moderncvstyle{classic}

\name{John}{Doe}
\address{Don Knuth Street, 42}{Tex City}
\photo[200pt][0pt]{example-image} % <<<<<<<<<<<<< set width 

\newcommand{\yshift}{-10ex} % vertical photo shift <<<<<<<<
\newcommand{\xshift}{2ex}  % horizontal  photo shift <<<<<<<<   

%************************************** added <<<<<<<<<<<<<<<
\makeatletter
\usepackage{xpatch}
\xpatchcmd{\makecvhead}
{\includegraphics[width=\@photowidth]{\@photo}}
{\begin{tikzpicture}\clip (0,0) circle (2cm);\node at (0,0){\includegraphics[width=\@photowidth]{\@photo}};\end{tikzpicture}}
{}{}
\xpatchcmd{\makecvhead}
{\usebox{\makecvheadpicturebox}}
{}
{}{}
\xpatchcmd{\makecvhead}
{\usebox{\makecvheadpicturebox}}
{\hspace*{\xshift}\raisebox{\yshift}{\usebox{\makecvheadpicturebox}}}
{}{}    
\makeatother
%************************************** 

\begin{document}    
    \makecvtitle    
\end{document}