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

populating a Photoshop document with 256 colors from color table or swatch group

Explorer ,
Apr 14, 2024 Apr 14, 2024

Copy link to clipboard

Copied

Is there an easy way of populating a grid with 256 colors from a color table or swatch group in a Photoshop document?

A grid similar to the 16 x 16 large thumbnail display in the swatch group panel would be ideal.

I tried taking a screen shot of the swatch group and pasting it into a Photoshop document, but the colors are all shifted.

I’m guessing the shift is based on a conversion from 16 bit to 8 bit.

Perhaps a template or a script is required to get all 256 colors into a Photoshop document.

Something like this, but with the colors still matching the original color table colors is what I'm after:

Untitled-3.jpg

TOPICS
Actions and scripting , Windows

Views

118

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

correct answers 2 Correct answers

People's Champ , Apr 14, 2024 Apr 14, 2024

Thy this

try {

var w = 32;
var h = 32;
var gap = 2;

var idx = 1;

for (var y = 0; y < 16; y++)
    {
    for (var x = 0; x < 16; x++)
        {
        var x0 = x*(w+gap);
        var y0 = y*(h+gap);

        var x1 = x0 + w;
        var y1 = y0 + h;

        app.activeDocument.selection.select([[x0, y0], [x1, y0], [x1, y1], [x0, y1]], SelectionType.REPLACE);

        // select color by index
        var d = new ActionDescriptor();
        var r = new ActionReference();
        r.putIndex(strin
...

Votes

Translate

Translate
Community Expert , Apr 14, 2024 Apr 14, 2024

My idea was:

 

Create a new document, 32x32 px or 64x64 px in size.

 

Use the spectrum or grascale gradient tool to fill the image with more than 256 discreet RGB colours.

 

Convert to Indexed Color mode (256 colours, no dither).

 

Image > Mode > Color Table can then be used to change colour palettes.

 

Use nearest neighbour interpolation and multiples of 200%, 400% etc. to resize larger. 

 

There are no gaps to separate the grid though.

 

 

Votes

Translate

Translate
Adobe
People's Champ ,
Apr 14, 2024 Apr 14, 2024

Copy link to clipboard

Copied

Thy this

try {

var w = 32;
var h = 32;
var gap = 2;

var idx = 1;

for (var y = 0; y < 16; y++)
    {
    for (var x = 0; x < 16; x++)
        {
        var x0 = x*(w+gap);
        var y0 = y*(h+gap);

        var x1 = x0 + w;
        var y1 = y0 + h;

        app.activeDocument.selection.select([[x0, y0], [x1, y0], [x1, y1], [x0, y1]], SelectionType.REPLACE);

        // select color by index
        var d = new ActionDescriptor();
        var r = new ActionReference();
        r.putIndex(stringIDToTypeID("colors"), idx);
        d.putReference(stringIDToTypeID("null"), r);
        executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
        ++idx;

        // fill selection
        var d = new ActionDescriptor();
        d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("fillContents"), stringIDToTypeID("foregroundColor"));
        d.putUnitDouble(stringIDToTypeID("opacity"), stringIDToTypeID("percentUnit"), 100);
        d.putEnumerated(stringIDToTypeID("mode"), stringIDToTypeID("blendMode"), stringIDToTypeID("normal"));
        executeAction(stringIDToTypeID("fill"), d, DialogModes.NO);

        app.activeDocument.selection.deselect();

        }
     }

} catch (e) { alert(e.line+ "\n\n" +e); }

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
Explorer ,
May 13, 2024 May 13, 2024

Copy link to clipboard

Copied

LATEST

Thanks!  I took break from this project to learn just enough UXP to be dangerous.

 

 

Is it possible to use a color table from an ACT file as the source for the 256 colors?

 

Or the selected swatch group?

 

Also, should this script use the document color profile by default, or should a color profile be designated?

 

Thanks again!

 

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
Community Expert ,
Apr 14, 2024 Apr 14, 2024

Copy link to clipboard

Copied

My idea was:

 

Create a new document, 32x32 px or 64x64 px in size.

 

Use the spectrum or grascale gradient tool to fill the image with more than 256 discreet RGB colours.

 

Convert to Indexed Color mode (256 colours, no dither).

 

Image > Mode > Color Table can then be used to change colour palettes.

 

Use nearest neighbour interpolation and multiples of 200%, 400% etc. to resize larger. 

 

There are no gaps to separate the grid though.

 

 

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