AppleScript 通过路径选择裁剪图像而不删除 Photoshop 中的像素

时间:2021-06-11 20:02:06

标签: applescript crop photoshop

我需要有关用于图片文件夹的 AppleScript 脚本的一些帮助:

  1. 从名为 Path 1 的已创建路径中进行选择
  2. 然后按该选择裁剪图片而不删除裁剪的像素

...

我在 AppleScript 中找到关闭“删除裁剪像素”的语法时遇到了问题......而且看起来没有这样的。我正在寻找一种保存这些像素的解决方案以及一种在 Applescript 中实现它的方法。

我的解决方案使用关键代码命令,这非常不方便,因为在运行脚本之前必须在 Photoshop 中手动关闭“删除裁剪像素”。 PS 之外的任何操作系统通知都会破坏脚本。

    
    tell application "Finder"
        set ThePath to choose folder with prompt "Please select folder:"
        set pictures_collection to every file of ThePath
    end tell
    
    repeat with anItem in pictures_collection
        
        tell application "Adobe Photoshop CS6"
            activate
            set anItem to anItem as string
            open file anItem
            do action "Make_A_Selection" from "Make_A_Selection" -- runs an action with just makes the selection
            set OpenedPicture to the current document
            tell application "System Events"
-- The option "Delete Cropped Pixels" in the PS Crop tool is turned OFF manually so the next code do not erace the pixels
                key code 8 -- press "C"
                delay 0.5
                key code 36  -- press "enter"
                delay 0.5
                key code 36 -- press "enter"
            end tell
            save OpenedPicture
            close OpenedPicture
        end tell
    end repeat
    return input
end run

所以我寻找更有效的方法,但不幸的是我不知道如何在下一个脚本中实现不“删除裁剪像素”的选项:

on run {input}
    
    tell application "Finder"
        set ThePath to choose folder with prompt "Please select folder:"
        set pictures_collection to every file of ThePath
    end tell
    
    repeat with anItem in pictures_collection
        
        tell application "Adobe Photoshop CS6"'s document 1
            activate
            set anItem to anItem as string
            open file anItem
            create selection path item 1
            tell application "Adobe Photoshop CS6"
                tell current document
                    set theCropBounds to bounds of selection
                    crop bounds theCropBounds
                end tell
            end tell
                save OpenedPicture
                close OpenedPicture
        end tell
    end repeat
    return input
end run

我查看了 photoshop-cs6-applescript-reference.pdf 但据我所知,我只能设置作物的坐标。 任何帮助将不胜感激。

0 个答案:

没有答案
相关问题