我一直在搜索google.com几个小时试图找到一种方法来做到这一点,但没有答案。无处不在调整大小,但没有任何关于仅调整指定宽度的内容。
Automator或AppleScript中是否有任何方法可以仅将图像调整为指定的宽度,而不仅仅是最长的尺寸?我需要输出的图像是特定的宽度(例如200px)。
答案 0 :(得分:4)
您可以使用普通AppleScript和名为 sips 的shell实用程序执行此操作:
on open droppings
repeat with everyDrop in droppings
set originalFile to quoted form of POSIX path of (everyDrop as text)
tell application "Finder"
set originalName to everyDrop's name
set imageContainer to (everyDrop's container as text)
end tell
set reSizedName to "200W" & originalName
set outputPath to quoted form of POSIX path of (imageContainer & reSizedName)
do shell script "sips --resampleWidth 200 " & originalFile & " --out " & outputPath
end repeat
end open
on run
display dialog "Drop some Image Files to Re-size them all to 200 pixels wide" buttons {"Aye Aye"} default button "Aye Aye"
end run
这样可以保留原始图像的纵横比,只需将宽度重新调整为200像素即可。希望您能看到自己的工作流程所需的更改位置。
如果要删除图像文件夹以及单个文件,请将其作为一个小滴:
on open droppings
repeat with everyDrop in droppings
if (info for everyDrop)'s folder is true then
tell application "Finder" to set allImageFiles to everyDrop's every file
repeat with eachFile in allImageFiles
my SetWidthTo200(eachFile)
end repeat
else
my SetWidthTo200(everyDrop)
end if
end repeat
end open
to SetWidthTo200(img)
set originalFile to quoted form of POSIX path of (img as text)
tell application "Finder"
set originalName to img's name
set imageContainer to (img's container as text)
end tell
set reSizedName to "200W" & originalName
set outputPath to quoted form of POSIX path of (imageContainer & reSizedName)
do shell script "sips --resampleWidth 200 " & originalFile & " --out " & outputPath
end SetWidthTo200
on run
display dialog "Drop some Image Files to Re-size them all to 200 pixels wide" buttons {"Aye Aye"} default button "Aye Aye"
end run
仍然没有错误检查或检查以确保文件确实是图像文件,因此请记住这一点。
答案 1 :(得分:0)
以下是OSX Tips使用automator调整图片大小的摘要