3
$\begingroup$

Say I import a TIFF, JPEG, or PDF image. How can I quickly determine the original aspect ratio of the image so that I can properly scale its size? I have thus far been unable to find an answer looking through the manual.

$\endgroup$
1
  • $\begingroup$ ImageAspectRatio or ImageDimensions should do the trick. $\endgroup$
    – cormullion
    Commented Mar 24, 2013 at 14:41

2 Answers 2

4
$\begingroup$

ImageDimensions will give you the pixel dimensions of an imported image, from which can calculate the aspect ratio:

img = Import["http://www.eschertile.com/pic/ss-2.jpg"];

enter image description here

ImageDimensions[img]
{858, 705}
$\endgroup$
1
  • 2
    $\begingroup$ And ImageAspectRatio in versions 8 and 9... :) $\endgroup$
    – cormullion
    Commented Mar 24, 2013 at 14:43
7
$\begingroup$

If you want to know the aspect ration of the image without importing the image itself, you can use "ImageSize" as last parameter to Import

N[Divide @@ Reverse@
  Import["http://www.eschertile.com/pic/ss-2.jpg", "ImageSize"]]

which gives the same value of 0.821678 as

ImageAspectRatio[Import["http://www.eschertile.com/pic/ss-2.jpg"]] // N
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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