이미지 이벤트로 사진의 크기를 조정할 수있는 간단한 AppleScript가 있습니다. 사진은 모든 축구 선수 들이며, 모두 "1.jpg", "4.jpg"등과 같이 번호가 지정됩니다. 내가 겪게되는 문제는 다른 디렉토리에서 플레이어의 여러 배치를 수행 할 때 스크립트가 동일한 파일 이름을 가지고 이전에 수행 된 다른 팀의 사진으로 사진을 덮어 쓰게 될 때입니다. 다시 말하지만,이 사진들은 모두 다른 디렉토리에 배치되었습니다. 최종 결과는 2 ~ 3 번 성공적으로 실행 한 후 플레이어의 형식이 변경된 사진이 혼란스러워집니다.이미지 이벤트 용 스크립트가 이전에 동일한 이름의 파일을 다시 포맷 한 파일을 덮어 쓰고 있습니다.
다음은 이미지 이벤트를 호출하는 스크립트입니다.
on open some_items
repeat with this_item in some_items
try
rescale_and_save(this_item)
end try
end repeat
end open
to rescale_and_save(this_item)
tell application "Image Events"
launch
set the target_width to 290
-- open the image file
set this_image to open this_item
set typ to this_image's file type
copy dimensions of this_image to {current_width, current_height}
if current_width is greater than current_height then
scale this_image to size target_width
else
-- figure out new height
-- y2 = (y1 * x2)/x1
set the new_height to (current_height * target_width)/current_width
scale this_image to size new_height
end if
tell application "Finder" to set new_item to ¬
(container of this_item as string) & "" & (name of this_item)
save this_image in new_item as typ
end tell
end rescale_and_save
감사합니다. –