This question is pretty simple: I'd like to have the possibility to get the exact size of a picture in LaTeX with, for example, the macro \the.
In fact, I've founded the way \settoheight{} and so on, but it didn't work at all. What I've got doesn't match with what I can see in the image properties (I suppose that's the name in English). The result: 8pt versus 1300 pixels. It's may be a mis-use...
Edit: In the end, my aim was to find a way to fit the picture in LaTeX. If width and height were both less than the dimensions of the body, then it should just be centred. It look like this :
Require:
\usepackage{graphicx}
\usepackage{xifthen}
\usepackage{calc}
Code (pretty ugly, I agree):
% Centrering+fitting for image, with captation and label (not auto)
\newlength\imageheight
\newlength\imagewidth
\newcommand{\pic}[3]{%
\settoheight\imageheight{\includegraphics{pictures/#1.png}}%
\settowidth\imagewidth{\includegraphics{pictures/#1.png}}%
\ifthenelse{\lengthtest{\imagewidth > \textwidth}}{\ifthenelse{\lengthtest{\imageheight > \imagewidth}}{\par\vspace{0.95em}%
\begin{figure}
\centering\includegraphics[height=0.85\textheight]{pictures/#1.png}
\caption{#2}
\label{#3}
\end{figure}%
\par\vspace{0.95em}}{\par\vspace{0.95em}%
\begin{figure}
\centering\includegraphics[width=0.95\textwidth]{pictures/#1.png}
\caption{#2}
\label{#3}
\end{figure}%
\par\vspace{0.95em}}}{\ifthenelse{\lengthtest{\imageheight > \textheight}}{\par\vspace{0.95em}%
\begin{figure}
\centering\includegraphics[height=0.85\textheight]{pictures/#1.png}
\caption{#2}
\label{#3}
\end{figure}%
\par\vspace{0.95em}}{\par\vspace{0.95em}%
\begin{figure}
\centering\includegraphics{pictures/#1.png}
\caption{#2}
\label{#3}
\end{figure}%
\par\vspace{0.95em}}}}
%
To use it : put your png files in a "pictures" directory, then, just simply call the picture like this : \pic{name_whitout_extension}{Captation_if_needed}{Label_if_needed}.
Edit 2 :
Thanks to Martin Scharrer's easyfig package, I've got a more or less 1,6 times faster solution to put my pictures, centred, with the perfect size.
CTAN: http://www.ctan.org/pkg/easyfig
VC: https://bitbucket.org/martin_scharrer/easyfig
Version v1.2 – 2012/05/15
This could be useful for some others, I hope.


identify -verbose <image filename>to see it, or you could look at the metadata in IrfanView by pressingI. If no resolution is set, LaTeX assumes 72dpi. – Jake Apr 26 '12 at 21:16adjustboxpackage. It can addmin widthandmax widthoptions to\includegraphicsto only scale an image if it is wider or narrower than a certain width. – Martin Scharrer Apr 26 '12 at 22:30adjustboxnow includes keys to set captions and label as well as turning the content into a float. Also, check out my other packageeasyfig, which also might be useful for you. – Martin Scharrer Aug 17 '12 at 18:25