[Tex/LaTex] How to put round cornered frame around an image

graphicsmdframedrounded-corners

I want a nice colored frame around an image which has rounded corners. Here is my attempt, using mdframed, but, as you can see, the inner edge of the frame is a right-angle, and not rounded. I would like the inner edge of the frame to overlay (chop off) the corners of the image to produce a rounded inner edge. Is there a nice easy way to do this?

\documentclass{article} 
\usepackage[framemethod=TikZ]{mdframed} 
\usepackage{graphicx}

\begin{document} 

\parindent=0pt
\baselineskip=0pt
\parskip=0pt


\def\myimage{c:/images/donald.png}

\begin{mdframed}[roundcorner=5pt, leftmargin=2cm,innertopmargin=0pt,innerbottommargin=0pt, innerleftmargin=0pt,innerrightmargin=0pt, innerlinewidth=0pt, middlelinewidth=0pt,outerlinewidth=10pt, outerlinecolor=red]% 
\hsize=5cm\includegraphics[width=5cm, height=5cm]{\myimage}
\end{mdframed}% 

\end{document} 

Result

Best Answer

Run with xelatex

\documentclass{article} 
\usepackage{pstricks,graphicx}
\newsavebox\IBox

\begin{document}    
\leavevmode
\savebox\IBox{\includegraphics{/tmp/donald}}
\put(0,0){\usebox\IBox}%
\psframe[framearc=0.2,framesep=0pt, cornersize=relative,
  linecolor=blue,linewidth=3mm](\wd\IBox,\ht\IBox)
\end{document}

enter image description here

and the same with clipping theimage:

\savebox\IBox{\includegraphics{/tmp/donald.png}}
\begin{pspicture}(\wd\IBox,\ht\IBox)
\psclip{\psframe[framearc=0.7,linestyle=none](\wd\IBox,\ht\IBox)}
\rput[lb](0,0){\usebox\IBox}%
\endpsclip
\psframe[framearc=0.7,framesep=0pt, cornersize=relative,
  linecolor=blue,linewidth=4mm](\wd\IBox,\ht\IBox)
\end{pspicture}

enter image description here

Related Question