How to put round cornered frame around an image
As Martin mentioned in the comment and I think mdframed
is to break a butterfly on a wheel, I want to present a tikz-Solution:
\documentclass{article}
\usepackage{tikz}
\usepackage{xparse}
\newsavebox\MyPicture
%\roundedpicture[graphcis-setup][tikz-setup]{graphics path}
\NewDocumentCommand{\roundedpicture}%
{O{width=0.6\linewidth}
O{draw=blue,line width=6pt,rounded corners=5pt}
m}{%
\savebox\MyPicture{\includegraphics[#1]{#3}}%
\begin{tikzpicture}%
\draw [path picture={%
\node at (path picture bounding box.center) {%
\usebox\MyPicture};},#2]
(0,0) rectangle (\wd\MyPicture,\ht\MyPicture);
\end{tikzpicture}%
}
\begin{document}
\roundedpicture[width=5cm]{donald-duck}
\roundedpicture{donald-duck}
\end{document}
ORIGINAL POST uses mdframed
You can change the behavior of the background. By default it is drawn as a filled rectangle.
With the following code you put a dummy in the environment to get the picture in the foreground.
\documentclass{report}
\usepackage{lipsum}
\usepackage[framemethod=TikZ]{mdframed}
\mdfdefinestyle{short}{roundcorner=5pt, leftmargin=2cm,innertopmargin=0pt,innerbottommargin=0pt, innerleftmargin=0pt,innerrightmargin=0pt, innerlinewidth=0pt, middlelinewidth=0pt,outerlinewidth=10pt, outerlinecolor=red}
\usetikzlibrary{backgrounds}
\makeatletter
\newrobustcmd\addtikzsetting[1]{%
\appto\md@tikz@settings{#1}%
}
\addtikzsetting{%
\tikzset{mdfbackground/.style={path picture={
\node at (path picture bounding box.center) {%
\includegraphics[height=5cm,width=5cm]{donald-duck}
};}}}}
\makeatother
\begin{document}
\begin{mdframed}[style=short,]
\hsize=5cm\rule{0pt}{5cm}
\end{mdframed}
\end{document}
I think mdframed
isn't the correct environment. You should create you own environment via tikz.
Now the modification with a new command so that it can be centered or whatever you want.
\documentclass{report}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage[framemethod=TikZ]{mdframed}
\mdfdefinestyle{short}{roundcorner=10pt,innertopmargin=0pt,innerbottommargin=0pt, innerleftmargin=0pt,innerrightmargin=0pt, innerlinewidth=0pt, middlelinewidth=0pt,middlelinewidth=10pt, middlelinecolor=red,leftmargin=0pt,rightmargin=0pt}
\usepackage{xparse}
\makeatletter
\newsavebox\MyPicture
%\roundedpicture[mdframed-setup][graphic-setup]{graphics-name}
\NewDocumentCommand{\roundedpicture}{o o m}{%
\savebox\MyPicture{\includegraphics[#2]{#3}}%
\begin{minipage}{\dimexpr\wd\MyPicture+20pt\relax}
\appto\md@tikz@settings{%
\tikzset{mdfbackground/.style={path picture={%
\node at (path picture bounding box.center) {\includegraphics[#2]{#3}};}%
}%
}%
}%
\begin{mdframed}[style=short,#1,nobreak]
\hsize=\dimexpr\wd\MyPicture\relax%
\rule{0pt}{\dimexpr\ht\MyPicture+\dp\MyPicture\relax}
\rule{\dimexpr\wd\MyPicture\relax}{0pt}
\end{mdframed}%
\end{minipage}
}
\makeatother
\begin{document}
\begin{center}
\roundedpicture[][width=3cm,height=5cm,keepaspectratio]{donald-duck}
\end{center}
\end{document}
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}
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}