# how to get the size of a \pgfdeclareimage

Basically I want to use a TikZ node to frame a pgfimage, so later on, I will add more and connect them as I see fit. I have this:

\pgfdeclareimage[width=10em]{image1}{images/image1}
\begin{tikzpicture}
\node (MM) [rectangle,draw,thick,minimum width=10.15em,label=below:Description]{\pgfbox[center,center]{\pgfuseimage{image1}}};
\end{tikzpicture}


So now I need to get the height of image1 to add minimum height property in the node declaration. This way I can get a dynamic framing independent of the aspect ratio of the image. Maybe it's an easy task but I'm newbie to this and can't seem to find the information I need in the documentation.

-
Welcome to TeX.sx! Why don’t you set greater inner xsep and inner ysep values instead of using minimum width and minimum height? –  Qrrbrbirlbel Mar 5 '13 at 18:23
thanks for the reply, but with that I have the same problem. I don't know to which value I should set the inner ysep, since depending on the aspect ratio, it will vary (I'm only fixing width=10em), I could manually adjust it but in the future I want to put more images in an automated way. –  Marco Martins Mar 5 '13 at 19:17

\pgfdeclareimage does not use or measure the image, but you can get the height by using LaTeX's \settoheight:

\documentclass{article}
\usepackage{tikz}

\newlength\imageheight

\begin{document}

\pgfdeclareimage[width=10em]{image1}{images/image1}
\settoheight{\imageheight}{\pgfuseimage{image1}}
\begin{tikzpicture}
\node (MM) [
rectangle,
draw,
thick,
minimum width=10.15em,
minimum height=\the\dimexpr\imageheight+.15em\relax,
label=below:Description
]{\pgfbox[center,center]{\pgfuseimage{image1}}};
\end{tikzpicture}

\end{document}

-
thanks, worked like a charm ;) –  Marco Martins Mar 5 '13 at 20:19