0

Photoshop で一連のファイルの各ファイル名をテキスト レイヤーに変換 (および保存) するにはどうすればよいですか?

フォルダ 1: 数百のファイル

フォルダ 2: ほぼ同じファイルですが、それぞれのファイル名が画像に貼り付けられています

ここにハッキングされたスニペットがあります。うまくいかないように見えるエラーは、activeDocument を現在開いているものに設定する方法です。http://pastebin.com/b0fqG9v4

4

2 に答える 2

5

回答済みとしてマークされていないので、誰かがそのようなことを気にかけている場合に備えて、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 ();
    }
}
于 2011-01-01T00:53:10.937 に答える
3

どうやら、Photoshop は Javascript を介してスクリプト可能であるため、モデルとしてダミー ファイルを使用すると、必要なことを実行できるはずです。Photoshop スクリプトに関するリソースを次に示します。

于 2010-12-27T08:26:08.613 に答える