【问题标题】:Automate Batch Script - Convert filenames to text in Photoshop自动化批处理脚本 - 在 Photoshop 中将文件名转换为文本
【发布时间】:2010-12-27 07:51:10
【问题描述】:

如何在 Photoshop 中将一堆文件的每个文件名转换为文本层(并保存)?

文件夹 1:数百个文件

文件夹 2:几乎相同的文件,但每个文件的文件名都贴在图像上

这是一个被破解的sn-p。我似乎无法解决的错误是如何将 activeDocument 设置为当前打开的。 http://pastebin.com/b0fqG9v4

【问题讨论】:

    标签: javascript adobe photoshop flash-cs5 extendscript


    【解决方案1】:

    还没有被标记为已回答,所以这里有一个用于 CS 的 javascript 示例(并且应该也适用于更高版本),以防有人关心这样的事情。这将打开源文件夹中的每个图像文件并添加一个新的文本层。将文件名设置为文本层的内容,然后将新文件保存到输出位置。

    它并没有真正尝试将文本放在图像上,这当然是可能的,但很复杂。

    如果您将颜色管理设置为在打开包含与工作色彩空间不匹配的嵌入式配置文件的文件时发出警告,您将看到配置文件不匹配对话框。您可以设置您的偏好来自动处理这种情况。

    function main ()
    {
        if (0 < app.documents.length)
        {
            alert ("Please close all open documents before running this script.");
            return;
        }
    
        // Use folder selection dialogs to get the location of the input files
        // and where to save the new output files.
        var sourceFolder = Folder.selectDialog ("Please choose the location of the source image files.", Folder.myDocuments);
        var destFolder = Folder.selectDialog ("Please choose a location where the new image files will be saved.", sourceFolder);
    
        var files = sourceFolder.getFiles();
        for (var i = 0; i < files.length; i++)
        {
            var f = files[i];
            if (f instanceof Folder)
                continue;
    
            // If there are no other documents open doc is the active document.
            var doc = app.open (f);
            var layer = doc.artLayers.add ();
            layer.bounds = [0,0,doc.width,doc.height];
    
            // Now make the layer into a text layer and set parameters.
            // The text will be centered, in the hideous default font, and white.
            // Note that font size depends not just on the point size, but also
            // on the resolution, which is NOT being set anywhere.
            layer.kind = LayerKind.TEXT;
            layer.textItem.position = [Math.round (doc.width / 2),Math.round (doc.height / 2)];
            layer.textItem.justification = Justification.CENTER;
            layer.textItem.color.rgb.hexValue = "FFFFFF";
            layer.textItem.size = 60;
    
            // Get the file name and set it as the text this assumes the full path is not wanted.
            // to set the full path swap fsname for name.
            layer.textItem.contents = File.decode (f.name);
    
            doc.flatten ();
    
            // Save as a new JPG file with these options.
            var options = new JPEGSaveOptions ();
            options.quality = 8;
    
            var outputFile = new File (destFolder.absoluteURI + "/" + f.name);
            doc.saveAs (outputFile, options, false, Extension.LOWERCASE);
            doc.close ();
        }
    }
    

    【讨论】:

      【解决方案2】:

      显然,Photoshop 可以通过 Javascript 编写脚本,因此使用虚拟文件作为模型,您应该能够执行所需的操作。以下是一些关于 Photoshop 脚本的资源:

      【讨论】:

      • 在这一点上,我对某人现有的这种常见操作的 sn-p 感到满意......但是,你要求它 - 发布一个非常黑客的 sn-p @pastebin.com/b0fqG9v4 - - 遇到致命错误,不确定如何将 activeDocument 设置为当前打开的文件
      猜你喜欢
      • 1970-01-01
      • 2023-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多