Reading bitmap resolution in maxscript

Reading bitmap resolution in maxscript

Anonymous
Not applicable
2,320 Views
2 Replies
Message 1 of 3

Reading bitmap resolution in maxscript

Anonymous
Not applicable

I am trying to write a script that reads the width and height of an image, and divides that by the resolution (DPI) to get the actual size of the image.    

 

 

Width and height are easy, but I can't find the resolution through maxscript.  I know this information is saved with the image, because when i open the image in photoshop or even windows paint, I am able to see the resolution.

 

Anyone know if this is possible?

 

Thanks!

0 Likes
Accepted solutions (1)
2,321 Views
2 Replies
Replies (2)
Message 2 of 3

Swordslayer
Advisor
Advisor
Accepted solution

This will give you image size in inches (multiply by 2.54 if you want centimeters):

 

img = (dotNetClass "System.Drawing.Image").FromFile @"image.jpg"
imgSize = [img.Height / img.VerticalResolution, img.Width / img.HorizontalResolution]
img.Dispose()

 

Message 3 of 3

Anonymous
Not applicable

This works perfectly!  Thank you so much...I literally spent hours looking for this information before I decided to post my question to the forum.

0 Likes