Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

TheMTtakeover

macrumors 6502
Original poster
Aug 3, 2011
470
7
I was wondering if someone has seen or has code or know's how to go about coding something like this. I essentially want the apple script to run numbers through the following equations.

Untitled-2_zpsb22a6c32.jpg


I want it to come up and ask for the width resolution in pixels, the height resolution in pixels, and diagonal size in inches and then take those numbers and to calculate the diagonal resolution in pixel and then from there calculate the PPI.

Any help at all is greatly appreciated!
 

Zeuzerian

macrumors newbie
Dec 26, 2012
1
0
Denmark
Hey

Just wrote this, and gave it a try for my 13.3 inch (1440x900) pixels display, that gave me a ppi of 128, which is correct, as far as I know.

Code:
set diagInInches to text returned of (display dialog "Enter the Diagonal Screen Size in inches :" default answer "?")
set screenResX to text returned of (display dialog "Enter horizontal screen size in pixels (x)" default answer "?")
set screenResY to text returned of (display dialog "Enter vertical screen size in pixels (y)" default answer "?")

set dp to (screenResX * screenResX + screenResY * screenResY) ^ (1 / 2)
set ppi to dp / diagInInches

display dialog "PPI for a " & diagInInches & " inch screen, with a resolution of " & screenResX & "x" & screenResY & " pixels, is " & (round (ppi * 100) / 100)

Best regards
-Zeuz
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.