xv

ASOD: Calculate New Image Size

Sep 20, 2011 18:57

This is something I needed to do to change the dimensions of a slideshow. I'm used to apps doing it automatically, so I didn't know the formula. Put a zero in the target field you want to solve for.

set {Source_Height, Source_Width} to {540, 720}

set {Target_Height, Target_Width} to {1600, 0}

if Target_Height > 0 then
{Target_Height, round Target_Height / (Source_Height / Source_Width) rounding down}
else
{round Target_Width / (Source_Width / Source_Height) rounding down, Target_Width}
end if

math, applescript

Previous post Next post
Up