Pictures in boxes with rounded corners
watermark graphics
is a tcolorbox
option which uses graphics file as box background. If no text is desired inside upper or lower parts, height
option fixes box size.
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\begin{document}
\begin{tcolorbox}[enhanced, watermark graphics=frog, watermark overzoom=1.0, title=example]
\lipsum[1]
\end{tcolorbox}
\begin{tcolorbox}[enhanced, watermark graphics=frog, watermark overzoom=1.0, notitle, height=5cm]
\end{tcolorbox}
\end{document}
Another option could be to use clip upper
option, which adjust upper part to interior size and form. In this case \includegraphics
command forms the upper part. Following code is copied from page 166 in tcolorbox
(v3.90) documentation.
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\newcommand{\mygraphics}[2][]{%
\tcbox[enhanced,boxsep=0pt,top=0pt,bottom=0pt,left=0pt,
right=0pt,boxrule=0.4pt,drop fuzzy shadow,clip upper,
colback=black!75!white,toptitle=2pt,bottomtitle=2pt,nobeforeafter,
center title,fonttitle=\small\sffamily,title=\detokenize{#2}]
{\includegraphics[width=\the\dimexpr(\linewidth-4mm)/2\relax]{#2}}}
\begin{document}
\mygraphics{frog}
\mygraphics{lion}
\end{document}
update tcolorbox
more recent versions include command tcbincludegraphics
which combines an includegraphics
command inside a tcolorbox
. Therefore previous examples can be simplified. More information can be found in section 11 Inclusion of Boxed Image Files. Here you have some examples:
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\tcbset{colframe=red!70!black,
size=tight, boxrule=1mm, arc=2mm, auto outer arc,
nobeforeafter}
\begin{document}
\tcbincludegraphics{frog}
\tcbincludegraphics[width=.5\linewidth, graphics options={width=3cm}]{frog}
%
\tcbincludegraphics[width=.5\linewidth, hbox, graphics options={width=3cm}]{frog}
\end{document}
Since tcolorbox
is implemented using tikz
, this is actually simpler.
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\sbox0{\includegraphics{example-image}}%
\path[clip,draw,rounded corners=1.5cm] (0,0) rectangle (\wd0,\ht0);
\path (0.5\wd0,0.5\ht0) node[inner sep=0pt]{\usebox0};
\end{tikzpicture}
\end{document}