1
我有一个简单的Applescript来调整与图像事件的照片。这些照片都是足球运动员,所以他们都以“1.jpg”,“4.jpg”等数字命名。我遇到的问题是当我在不同目录中执行多批玩家时,脚本将用另一个来自另一个团队的具有相同文件名并且之前完成的照片覆盖照片。再次,这些照片全部放置在不同的目录中。最终的结果是,在成功运行两三次之后,重新格式化的球员照片会变得混乱。图像事件的脚本覆盖我的文件与以前格式相同的文件
下面是我在脚本中调用Image Events的内容。
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
谢谢,这很好。 –