如何实现 Photoshop 自动化?

发布于 2024-07-17 13:47:10 字数 223 浏览 9 评论 0原文

我正在尝试在 Photoshop 中自动执行扫描/裁剪照片的过程。 我需要一次扫描 3 张照片,然后使用 Photoshop 的“裁剪和拉直照片”命令,该命令会创建 3 个单独的图像。 之后我想将每个新创建的图像保存为 PNG 格式。

我查看了 JSX 脚本,它们似乎很有希望。 我所描述的内容是否可以在 Photoshop 中使用 JavaScript 或 VBScript 或其他方式实现自动化?

I am trying to automate the process of scanning/cropping photos in Photoshop. I need to scan 3 photos at a time, then use Photoshop's Crop and Straighten Photos command, which creates 3 separate images. After that I'd like to save each of the newly created images as a PNG.

I looked at the JSX scripts and they seem to a lot of promise. Is what I described possible to automate in Photoshop using JavaScript or VBScript or whatever?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

猫九 2024-07-24 13:47:10

事实上,我在 adobe 的 Photoshop 论坛上得到了答案。 事实证明,Photoshop CS4 完全可以通过 JavaScript、VBScript 编写脚本,并附带一个非常强大的开发人员 IDE,它拥有您所期望的一切(调试器、监视窗口、颜色编码等)。 我完全被感动了。

以下摘录供参考:

您可以运行以下脚本,该脚本将在现有文件夹中创建一个新文件夹,并批量拆分所有文件,将其命名为existingFileName#001.png,并将它们放入新文件夹中(已编辑)

#target Photoshop
app.bringToFront;
var inFolder = Folder.selectDialog("Please select folder to process"); 
if(inFolder != null){
    var fileList = inFolder.getFiles(/\.(jpg|tif|psd|)$/i);
    var outfolder = new Folder(decodeURI(inFolder) + "/Edited");
    if (outfolder.exists == false) outfolder.create();
    for(var a = 0 ;a < fileList.length; a++){
    if(fileList[a] instanceof File){
        var doc= open(fileList[a]);
        doc.flatten();
        var docname = fileList[a].name.slice(0,-4);
        CropStraighten();
        doc.close(SaveOptions.DONOTSAVECHANGES); 
        var count = 1;
        while(app.documents.length){
            var saveFile = new File(decodeURI(outfolder) + "/" + docname +"#"+ zeroPad(count,3) + ".png");
            SavePNG(saveFile);
            activeDocument.close(SaveOptions.DONOTSAVECHANGES) ; 
            count++;
            }
        }
    }
};
function CropStraighten() {
    function cTID(s) { return app.charIDToTypeID(s); };
    function sTID(s) { return app.stringIDToTypeID(s); };
    executeAction( sTID('CropPhotosAuto0001'), undefined, DialogModes.NO );
};
function SavePNG(saveFile){
    pngSaveOptions = new PNGSaveOptions(); 
    pngSaveOptions.embedColorProfile = true; 
    pngSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE; 
    pngSaveOptions.matte = MatteType.NONE; 
    pngSaveOptions.quality = 1; 
    pngSaveOptions.PNG8 = false; //24 bit PNG
    pngSaveOptions.transparency = true; 
    activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE); 
}

function zeroPad(n, s) { 
    n = n.toString(); 
    while (n.length < s) n = '0' + n; 
    return n; 
};

访问此处查看完整帖子。

I actually got the answer on the Photoshop forums over at adobe. It turns out that Photoshop CS4 is totally scriptable via JavaScript, VBScript and comes with a really kick-ass Developer IDE, that has everything you'd expect (debugger, watch window, color coding and more). I was totally impressed.

Following is an extract for reference:

you can run the following script that will create a new folder off the existing one and batch split all the files naming them existingFileName#001.png and put them in the new folder (edited)

#target Photoshop
app.bringToFront;
var inFolder = Folder.selectDialog("Please select folder to process"); 
if(inFolder != null){
    var fileList = inFolder.getFiles(/\.(jpg|tif|psd|)$/i);
    var outfolder = new Folder(decodeURI(inFolder) + "/Edited");
    if (outfolder.exists == false) outfolder.create();
    for(var a = 0 ;a < fileList.length; a++){
    if(fileList[a] instanceof File){
        var doc= open(fileList[a]);
        doc.flatten();
        var docname = fileList[a].name.slice(0,-4);
        CropStraighten();
        doc.close(SaveOptions.DONOTSAVECHANGES); 
        var count = 1;
        while(app.documents.length){
            var saveFile = new File(decodeURI(outfolder) + "/" + docname +"#"+ zeroPad(count,3) + ".png");
            SavePNG(saveFile);
            activeDocument.close(SaveOptions.DONOTSAVECHANGES) ; 
            count++;
            }
        }
    }
};
function CropStraighten() {
    function cTID(s) { return app.charIDToTypeID(s); };
    function sTID(s) { return app.stringIDToTypeID(s); };
    executeAction( sTID('CropPhotosAuto0001'), undefined, DialogModes.NO );
};
function SavePNG(saveFile){
    pngSaveOptions = new PNGSaveOptions(); 
    pngSaveOptions.embedColorProfile = true; 
    pngSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE; 
    pngSaveOptions.matte = MatteType.NONE; 
    pngSaveOptions.quality = 1; 
    pngSaveOptions.PNG8 = false; //24 bit PNG
    pngSaveOptions.transparency = true; 
    activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE); 
}

function zeroPad(n, s) { 
    n = n.toString(); 
    while (n.length < s) n = '0' + n; 
    return n; 
};

Visit here for complete post.

七度光 2024-07-24 13:47:10

我刚刚发现这个脚本正好为我完成了工作! 它会自动裁剪和裁剪 拉直照片并将每个结果保存到您指定的目录中。

http://www.tranberry.com/photoshop/photoshop_scripting/PS4GeeksOrlando/IntroScripts /cropAndStraightenBatch.jsx

保存到本地然后在PS=>File=>Command=>Browse

P.SI中运行它在注释中发现它说可以在Mac上双击直接执行脚本Finder 或 Windows 资源管理器。

此处脚本的备份要点

I just found this script just did the work for me! It automatically crop & straighten the photo and save each result to directory you specified.

http://www.tranberry.com/photoshop/photoshop_scripting/PS4GeeksOrlando/IntroScripts/cropAndStraightenBatch.jsx

Save it to local then run it in the PS=>File=>Command=>Browse

P.S I found in the comment it said the script can be executed directly by double clicking from Mac Finder or Windows Explorer.

Backup gist for the script here

久光 2024-07-24 13:47:10

您尝试过使用 Photoshop Actions 吗? 我现在不关心扫描部分,但其余的都可以通过操作轻松完成。

Have you tried using Photoshop Actions? I don't now about the scanning part, but the rest can all be done by actions quite easily.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文