[Tex/LaTex] set a maximum width and height for an image

dimensionsgraphics

I would like to define a maximum height and a maximum width for an image at same time. I suppose there must be a package to do this, but actually I'm unable to find it…

Best Answer

You can use the keepaspectratio key and define your graphics as:

\includegraphics[width=10cm,height=10cm,keepaspectratio]{image}

The MWE is as follows:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=2cm,height=3cm,keepaspectratio]{./graphics/amato}
\includegraphics[width=2cm,height=3cm,keepaspectratio]{./graphics/cardtrick}
\end{document}

enter image description here

Experiment with images with different aspect ratios to see the effect.