Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
1  
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
add comment

1 Answer 1

up vote 3 down vote accepted

\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}
share|improve this answer
    
thanks, worked like a charm ;) –  Marco Martins Mar 5 '13 at 20:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.