Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
11

Using AI to rename our layers

Community Beginner ,
Oct 16, 2023 Oct 16, 2023

Let's face it: we often rename our layers at the end of a project, when we know that a colleague or client will need access to our work 🫣

Why not implement automatic layer renaming using AI?

Today's generative AIs are capable of describing the content of an image, and therefore potentially of a layer? And we can force it to give a simplified name, to avoid long names.

It might not be perfect, but for a composition of a hundred layers, it would save an incredible amount of time, whatever the software (Photoshop, After Effects, Illustrator...).

And we'd no longer be ashamed to show off our layers 😛

Idea No status
TOPICS
macOS , Windows
915
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
2 Comments
Mentor ,
Oct 16, 2023 Oct 16, 2023

I can see Ps Ai naming from content :

lights when blend mode is addition+ and small touches

shadows when blend mode is multiply+
full pixel content Could be renamed as tagged ("chicken running in a field" ?)…

Translate
Report
Community Expert ,
Oct 17, 2023 Oct 17, 2023
LATEST

Until such a day:

 

 
 
 
 
 
/* https://www.ps-scripts.com/viewtopic.php?p=170072#p170072 */

// Active Layer to Blend Mode Name.jsx
// Stephen Marsh, v1.1 11th December 2021

#target photoshop

// If layer name = Layer 1 | Layer 02 | Layer 003 etc. (case sensitive)
if (app.activeDocument.activeLayer.name.match(/^Layer \d+/)) {
    // Call function
    lyrNameToBlendName();
}

function lyrNameToBlendName() {
    var lyrBlendMode = app.activeDocument.activeLayer.blendMode.toString().replace(/(?:^.+\.)(.+)/, '$1');
    var lyrBlendLC = lyrBlendMode.replace(/LIGHT$/, ' LIGHT').replace(/MIX$/, ' MIX').replace(/COLOR$/, ' COLOR').replace(/DODGE$/, ' DODGE').replace(/BURN$/, ' BURN').replace(/LINEAR DODGE$/, 'LINEAR DODGE (ADD)');
    var lyrBlendPC = (sentenceCase(lyrBlendLC));

    function sentenceCase(str) {
        /* https://www.geeksforgeeks.org/convert-string-to-title-case-in-javascript/ */
        if ((str === null) || (str === ''))
            return false;
        else
            str = str.toString();
        return str.replace(/\w\S*/g,
            function (txt) {
                return txt.charAt(0).toUpperCase() +
                    txt.substr(1).toLowerCase();
            });
    }

    var suffix = app.activeDocument.activeLayer.name.replace(/(?:.+)( \d+$)/, '$1');
    app.activeDocument.activeLayer.name = lyrBlendPC + suffix;
}

 

/* https://www.ps-scripts.com/viewtopic.php?p=170072#p170072 */

// All Top Level Layers to Blend Mode Name.jsx
// Stephen Marsh, v1.0 6th December 2021

#target photoshop

function main() {

    if (app.documents.length > 0) {

        var lyrCount = app.activeDocument.layers.length;

        for (var i = 0; i < lyrCount; i++) {

            // Layer sets
            //app.activeDocument.activeLayer = app.activeDocument.layers[i];
            // Layers
            app.activeDocument.activeLayer = app.activeDocument.artLayers[i];
            // If layer isn't background and the name = Layer 1 | Layer 02 | Layer 003 etc. (case sensitive)
            if (!app.activeDocument.activeLayer.isBackgroundLayer && app.activeDocument.activeLayer.name.match(/^Layer \d+/)) {
                try {
                    // Call the rename function
                    lyrNameToBlendName();
                } catch (e) { }
            }
        }


        function lyrNameToBlendName() {
            var lyrBlendMode = app.activeDocument.activeLayer.blendMode.toString().replace(/(?:^.+\.)(.+)/, '$1');
            var lyrBlendLC = lyrBlendMode.replace(/LIGHT$/, ' LIGHT').replace(/MIX$/, ' MIX').replace(/COLOR$/, ' COLOR').replace(/DODGE$/, ' DODGE').replace(/BURN$/, ' BURN').replace(/LINEAR DODGE$/, 'LINEAR DODGE (ADD)');
            var lyrBlendPC = (sentenceCase(lyrBlendLC));

            function sentenceCase(str) {
                /* https://www.geeksforgeeks.org/convert-string-to-title-case-in-javascript/ */
                if ((str === null) || (str === ''))
                    return false;
                else
                    str = str.toString();
                return str.replace(/\w\S*/g,
                    function (txt) {
                        return txt.charAt(0).toUpperCase() +
                            txt.substr(1).toLowerCase();
                    });
            }

            var suffix = app.activeDocument.activeLayer.name.replace(/(?:.+)( \d+$)/, '$1');
            app.activeDocument.activeLayer.name = lyrBlendPC + suffix;
        }

    } else {
        alert('There are no open files')
    };
}
app.activeDocument.suspendHistory('Rename layers', 'main()');

 

And:

 

/*
Selected Layers to Blend Mode Name v1.jsx
v1.0, 25th June 2022, Stephen Marsh
Based on the code that I wrote for:
https://www.ps-scripts.com/viewtopic.php?f=66&t=40800
*/

#target photoshop

function main() {

    // Save the current dialog display settings
    var savedDisplayDialogs = app.displayDialogs;
    app.displayDialogs = DialogModes.NO;

    // Select all layers
    app.runMenuItem(stringIDToTypeID("selectAllLayers"));

    // Get the selected layers: courtesy of jazz-y
    var s2t = stringIDToTypeID;
    (r = new ActionReference()).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
    r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
    var lrs = executeActionGet(r).getList(p),
        sel = new ActionReference();

    // Loop over the selected layers: courtesy of jazz-y
    for (var i = 0; i < lrs.count; i++) {
        sel.putIdentifier(s2t('layer'), p = lrs.getReference(i).getIdentifier(s2t('layerID')));
        (r = new ActionReference()).putIdentifier(s2t('layer'), p);
        (d = new ActionDescriptor()).putReference(s2t("target"), r);
        executeAction(s2t('select'), d, DialogModes.NO);

        // If layer name = Layer 1 | Layer 02 | Layer 003 etc. (case sensitive)
        if (app.activeDocument.activeLayer.name.match(/^Layer \d+/)) {
            // Call the layer rename function
            lyrNameToBlendName();
        }
    }
    // Finish the loop

    // Restore the dialogs
    app.displayDialogs = savedDisplayDialogs;
}


function lyrNameToBlendName() {
    var lyrBlendMode = app.activeDocument.activeLayer.blendMode.toString().replace(/(?:^.+\.)(.+)/, '$1');
    var lyrBlendLC = lyrBlendMode.replace(/LIGHT$/, ' LIGHT').replace(/MIX$/, ' MIX').replace(/COLOR$/, ' COLOR').replace(/DODGE$/, ' DODGE').replace(/BURN$/, ' BURN').replace(/LINEAR DODGE$/, 'LINEAR DODGE (ADD)').toLowerCase();
    var lyrBlendPC = (sentenceCase(lyrBlendLC));

    function sentenceCase(str) {
        /* https://www.geeksforgeeks.org/convert-string-to-title-case-in-javascript/ */
        if ((str === null) || (str === ''))
            return false;
        else
            str = str.toString();
        return str.replace(/\w\S*/g,
            function (txt) {
                return txt.charAt(0).toUpperCase() +
                    txt.substr(1).toLowerCase();
            });
    }

    var suffix = app.activeDocument.activeLayer.name.replace(/(?:.+)( \d+$)/, '$1');
    app.activeDocument.activeLayer.name = lyrBlendPC + suffix;
}

// Single history stage undo
activeDocument.suspendHistory("Selected Layers to Blend Mode Name v1.jsx", "main()");

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

Translate
Report
product-logoPhotoshop
Create gorgeous images, rich graphics, and incredible art.
Start Free Trial