ok so I have a script that resize images and photoshop CS2 I want to allow the user to supply just the width or just the height. But when I resize want to constrain the proportions but I don’t know how to do the math I think i"m on the right track but I’m probably way off
heres what I’ve got
set widthPix to ""
set heightPix to "200" as real
tell application "Adobe Photoshop CS2"
activate
set ruler units of settings to pixel units
set display dialogs to never
tell document 1
set CW to (width as pixels)
set CH to (height as pixels)
if widthPix is "" and heightPix is not "" then
set widthPix to (((CH / CW) * heightPix) + CW)
end if-
resize image width widthPix height heightPix
end tell
end tell
thanks you very much I was able to figure it out using the link you were close though
set widthPix to ""
set heightPix to "200" as real
tell application "Adobe Photoshop CS2"
activate
set ruler units of settings to pixel units
set display dialogs to never
tell document 1
set CW to (width as pixels)
set CH to (height as pixels)
if widthPix is "" and heightPix is not "" then
--widthPix = CW * heightPix / CH
set widthPix to (CW / heightPix) * CW
end if
resize image width widthPix height heightPix
end tell
end tell