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

Photoshop swatches to layers

New Here ,
Oct 19, 2020 Oct 19, 2020

Copy link to clipboard

Copied

Hello all,

 

 

I have a swatch of 400+ colors and i ill need to render them on layers.Is there any method to do that, other one by one?

 

Thank you,

Flo

Capture.JPG

 

 

 

TOPICS
Actions and scripting

Views

194

Translate

Translate

Report

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
Adobe
People's Champ ,
Oct 20, 2020 Oct 20, 2020

Copy link to clipboard

Copied

LATEST

Perhaps this script will solve your problem.

 

var fake_color = new SolidColor();

fake_color.cmyk.cyan    = 100;
fake_color.cmyk.magenta = 100;
fake_color.cmyk.yellow  = 100;
fake_color.cmyk.black   = 100;

var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("presetManager"));
r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

var list = executeActionGet(r).getList(stringIDToTypeID("presetManager")).getObjectValue(1).getList(stringIDToTypeID("name"));

var color_names = new Array();

for (var i = 0; i < list.count; i++) color_names.push(list.getString(i));

var i = 1;
var n = 0;

while (n < color_names.length)
    {
    app.foregroundColor = fake_color;

    var d = new ActionDescriptor();
    var r = new ActionReference();
    r.putIndex(stringIDToTypeID("colors"), i);
    d.putReference(stringIDToTypeID("null"), r);
    executeAction(stringIDToTypeID("select"), d, DialogModes.NO);

    if (app.foregroundColor.cmyk.cyan != fake_color.cmyk.cyan || app.foregroundColor.cmyk.magenta != fake_color.cmyk.magenta || app.foregroundColor.cmyk.yellow != fake_color.cmyk.yellow || app.foregroundColor.cmyk.black != fake_color.cmyk.black)
        {
        var d = new ActionDescriptor();
        var r = new ActionReference();
        r.putClass(stringIDToTypeID("contentLayer"));
        d.putReference(stringIDToTypeID("null"), r);
        var d1 = new ActionDescriptor();
        d1.putString(stringIDToTypeID("name"), color_names[n]);
        var d2 = new ActionDescriptor();
        var d3 = new ActionDescriptor();
        d3.putDouble(stringIDToTypeID("red"),   app.foregroundColor.rgb.red);
        d3.putDouble(stringIDToTypeID("green"), app.foregroundColor.rgb.green);
        d3.putDouble(stringIDToTypeID("blue"),  app.foregroundColor.rgb.blue);
        d2.putObject(stringIDToTypeID("color"), stringIDToTypeID("RGBColor"), d3);
        d1.putObject(stringIDToTypeID("type"), stringIDToTypeID("solidColorLayer"), d2);
        d.putObject(stringIDToTypeID("using"), stringIDToTypeID("contentLayer"), d1);
        executeAction(stringIDToTypeID("make"), d, DialogModes.NO);

        var d = new ActionDescriptor();
        var r = new ActionReference();
        r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
        d.putReference(stringIDToTypeID("null"), r);
        executeAction(stringIDToTypeID("selectNoLayers"), d, DialogModes.NO);

        ++n;
        }            

    ++i;
    }

 

 

Votes

Translate

Translate

Report

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