我编写了这个 AppleScript,它只是简单地检查并更改所选图片的分辨率,如有必要,使用“sips”将其更改为 304.00。
但是之后的图片有严重的问题。他们是:
- 丢失一些元数据。
- 图片中的路径被删除。
.psd
如果图片为任一格式或带图层格式,则所有图层合并为一个.tif
。
与我没有注意到的原始图片相比,可能还有更多差异。
我想问题在于“sips”如何工作的概念,但是我想知道这些问题是否有任何解决方法。我想在不改变原始图片的情况下使用“sips”,而只改变我想要的属性。
提前致谢。
这是我的脚本。
on run {input}
tell application "Finder"
set pictures_collection to selection
end tell
set Not304Resolution to {}
repeat with anItem in pictures_collection
set mgPath to POSIX path of (anItem as text)
set ResCheck to (do shell script "sips -g dpiHeight -g dpiWidth " & quoted form of POSIX path of mgPath)
if ResCheck does not contain "304.000" then
do shell script "sips -s dpiHeight 304 -s dpiWidth 304 " & quoted form of POSIX path of mgPath
set end of Not304Resolution to name of anItem as string
end if
end repeat
if length of Not304Resolution is not 0 then
tell me to activate
display dialog "Found pictures with wrong resolution : " & length of Not304Resolution & "
They are:
" & list2string(Not304Resolution, " ")
else
display dialog "All files have 304 resolution !"
end if
end run
on list2string(theFoldersList, theDelimiter)
set theBackup to AppleScript's text item delimiters
set AppleScript's text item delimiters to ASCII character 13
set theString to theFoldersList as string
set AppleScript's text item delimiters to theBackup
return theString
end list2string