How can I get the aspect ratio of an image and store it in a pgf macro for further calculations? For example:
\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
\includegraphics{image.jpg}
\begin{tikzpicture}
\pgfmatsetmacro{\aspectratio}{???} % This variable should contain the aspect ratio of image.jpg
\end{tikzpicture}
\end{document}
Best Answer
Here is an
\aspectratio
macro that either prints the aspect ratio or stores it in a macro given as optional argument. The *-form will do a global assignment, in case you need it. The macro (in the example it is\test
) can be used in\pgfmathsetmacro
or other environment accepting floating point numbers.