首页 > 解决方案 > AppleScript 问题使用 sip 更改图片的分辨率

问题描述

我编写了这个 AppleScript,它只是简单地检查并更改所选图片的分辨率,如有必要,使用“sips”将其更改为 304.00。

但是之后的图片有严重的问题。他们是:

与我没有注意到的原始图片相比,可能还有更多差异。

我想问题在于“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

标签: applescriptphotoshopresolutionsips

解决方案


推荐阅读