Wednesday, March 24, 2010

AppleScript에서 Photoshop 이용해서 특정 해상도로 image resize 해주기

포토샵을 이용해, Resolution 을 직접 지정해서 resize 해주는 예:
myResizeImage(200, 100)
on myResizeImage(newWidth, newHeight)
tell application "Adobe Photoshop CS4"
set myDoc to current document
set oldUnits to ruler units of settings
set ruler units of settings to pixel units
tell myDoc
set {w, h} to {width, height}
end tell
resize image myDoc width newWidth height newHeight resample method bicubic sharper
set ruler units of settings to oldUnits
end tell
end myResizeImage

다음은 레퍼런스에 있던 원래 코드. 잘 안된다고 함.
-- ========================
-- Create and save the 20 Mb file
-- ========================
tell application "Adobe Photoshop CS2"
set doc20 to current document
-- Resize to 20 Mb
set oldUnits to ruler units of settings
set ruler units of settings to pixel units
tell doc20
set {w, h} to {width, height}
-- newWidth is calculated based on the following formulas
-- 20Mb = ( 3 * (prct*w) * (prct*h) ) / 1024^2
-- newWidth = prct * w
set newWidth to ((20971520 / (w * h * 3)) ^ 0.5) * w
end tell
resize image doc20 width newWidth resolution 300 resample method bicubic sharper -- Works up to here
set ruler units of settings to inch units
resize image doc20 width oldWidth resample method none -- Errors on this line
set ruler units of settings to oldUnits
end tell
레퍼런스 :
Resize Image in Photoshop

No comments:

Post a Comment