Skip to main content
Jani.A
Participating Frequently
Mar 22, 2024 8:23 AM UTC
Question

printing color numbers in Photoshop

I need help with the print possibilities in Photoshop. 
When I have made a print, and found the ex. 20 colors to use, then I have named the colors.
Sometimes I give them names, in other situations they have numbers. However, I am looking for 

a way to print my design, with the color palette showing, with the names of them belonging to each color. 

Fingers crossed its possible and someone can help me 🙂 Thanx.

This topic is closed to new replies. Start a new post to keep the conversation going.

18 replies

c.pfaffenbichler
Community Expert
Community Expert
Apr 6, 2024 12:03 PM UTC

Have you tested the Script? 

Translate
Jani.A
Jani.AAuthor
Participating Frequently
Apr 9, 2024 5:13 AM UTC

Hi again, not yet, I don´t know how to implement the script you have att. 

Can you give me a short guide ?

 

Translate
c.pfaffenbichler
Community Expert
Community Expert
Apr 9, 2024 7:28 AM UTC

There seems to have been a mistake of mine, so I updated the code and it should work with an open gif now. 

 

Save the code as a txt-file, change the extension to .jsx and copy it into Photoshop’s Presets/Scripts-Folder; after restarting Photoshop it should be available under File > Scripts and can be assigned a Shortcut or used in an Action. 

Translate
c.pfaffenbichler
Community Expert
Community Expert
Apr 5, 2024 12:44 PM UTC

Well, in principle this may work. 

 

// get indexed color values of gif-image and create swatches in an rgb copy;
// thanks to peter gun, xbytor and r-bin;
// 2024, use it at your own risk;
if (app.documents.length > 0) {
var myDocument = activeDocument;
if (myDocument.mode == DocumentMode.INDEXEDCOLOR) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var filePath = myDocument.fullName;
// get gif color table;
readFromFile = function(fptr) {
var file = convertFptr(fptr);
file.open("r") || Error.runtimeError(9002, "Unable to open input file \"" +
                    file + "\".\r" + file.error);
file.encoding = 'BINARY';
var str = '';
str = file.read(file.length);
file.close();
return str;
};
convertFptr = function(fptr) {
var f;
if (fptr.constructor == String) {
f = File(fptr);
} else if (fptr instanceof File || fptr instanceof Folder) {
f = fptr;
} else {
throw "Bad file \"" + fptr + "\" specified.";
}
return f;
};
readByteHex = function(s) {  
function hexDigit(d) {  
if (d < 10) return d.toString();  
d -= 10;  
return String.fromCharCode('A'.charCodeAt(0) + d);  
}  
var str = '';  
s = s.toString();  

var ch = s.charCodeAt(0xA);  
str += hexDigit(ch >> 4) + hexDigit(ch & 0xF);  

return str;  
};
// hex to bin conversion  
Math.base = function(n, to, from) {  
      return parseInt(n, from || 10).toString(to);  
};
//load test image  
var img = readFromFile(activeDocument.fullName);  
hex = readByteHex(img);      // hex string of the 0xA byte  
bin = Math.base(hex,2,16);          // binary string of the 0xA byte  
tableSize = bin.slice(5,8);          // Get the 3 bit info that defines size of the ct  
switch(tableSize)  
{  
case '000': // 6 bytes table  
tablSize = 2  
break;  
case '001': // 12 bytes table  
tablSize = 4  
break;  
case '010': // 24 bytes table  
tablSize = 8  
break;  
case '011': // 48 bytes table  
tablSize = 16  
break;  
case '100': // 96 bytes table  
tablSize = 32  
break;  
case '101': // 192 bytes table  
tablSize = 64  
break;  
case '110': // 384 bytes table  
tablSize = 128  
break;  
case '111': // 768 bytes table  
tablSize = 256  
break;  
};
getTbColor = function(s, color) {   
function hexDigit(d) {  
if (d < 10) return d.toString();  
d -= 10;  
return String.fromCharCode('A'.charCodeAt(0) + d);  
}  
var tbStart = 0xD; // Start of the color table byte location  
var colStrSz = 3; // Constant -> RGB  
var str = '';  
s = s.toString();  

for (var i = tbStart+(colStrSz*color); i < tbStart+(colStrSz*color)+colStrSz; i++) {   
var ch = s.charCodeAt(i);  
str += hexDigit(ch >> 4) + hexDigit(ch & 0xF);  
}  

return str;  
};
var colorHex = [];  
importColors = function (){  
for (i=0; i< tablSize; i++){ // number of colors  
colorHex[i] = getTbColor(img, i);  
}  
};
importColors();  
function unique(arrayName){  
var newArray=new Array();  
label:for(var i=0; i<arrayName.length;i++ ){    
for(var j=0; j<newArray.length;j++ ){  
if(newArray[j]==arrayName[i])   
continue label;  
}  
newArray[newArray.length] = arrayName[i];  
}  
return newArray;  
};
colorHex = unique(colorHex);  
//alert (colorHex.length+"\n"+colorHex.join("\n"));
////////////////////////////////////
var theCopy = myDocument.duplicate();
// convert to rgb;
var desc5 = new ActionDescriptor();
desc5.putClass( stringIDToTypeID( "to" ), stringIDToTypeID( "RGBColorMode" ) );
executeAction( stringIDToTypeID( "convertMode" ), desc5, DialogModes.NO );
// extend canvas;
resetForeAndBackground ();
var numberPerLine = 7;
var theDist = 20;
var fromEdge = 20;
var theSide = (Number(theCopy.width)-(fromEdge*2)-theDist*(numberPerLine-1))/(numberPerLine);
var theY = fromEdge;
var theX = fromEdge-theSide-theDist;
theCopy.resizeCanvas(theCopy.width, theCopy.height+((theSide+theDist)*(Math.ceil(colorHex.length/numberPerLine))+fromEdge), AnchorPosition.BOTTOMCENTER);
// create shape layers;
for (var b = 0; b < colorHex.length; b++) {
    var theX = theX+theSide+theDist;
    var theWidth = theX+theSide+theDist;
    if (theX+theSide > myDocument.width) {
        var theWidth = theX;
        theX = fromEdge+theDist-theDist;
        theY = theY+theSide+theDist;
    };
// thanks to r-bin;
var t = colorHex[b];
(foreColor = new SolidColor).rgb.red = parseInt(t.substr(0,2),16);
foreColor.rgb.green =  parseInt(t.substr(2,2),16);
foreColor.rgb.blue = parseInt(t.substr(-2),16);
ellipseShapeLayer ([Math.round(theX), Math.round(theY), Math.round(theX+theSide), Math.round(theY+theSide)], [foreColor.rgb.red, foreColor.rgb.green, foreColor.rgb.blue], 0, [0,0,0])
createTextLayer (colorHex[b], [Math.round(theX+theSide/2), Math.round(theY+theSide+theDist)], theCopy.resolution)
};
theCopy.activeLayer = theCopy.layers[theCopy.layers.length-1];
////////////////////////////////////
app.preferences.rulerUnits = originalRulerUnits;
};
};
////// reset fore- and background color //////
function resetForeAndBackground () {
var desc2 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty( charIDToTypeID( "Clr " ), charIDToTypeID( "Clrs" ) );
desc2.putReference( charIDToTypeID( "null" ), ref1 );
executeAction( charIDToTypeID( "Rset" ), desc2, DialogModes.NO );
};
////// create ellipse shape layer //////
function ellipseShapeLayer (theBounds, theColor, strokeWidth, strokeColor) {
try {
// Make outer oval
var idPxl = charIDToTypeID( "#Pxl" );
var idPnt = charIDToTypeID( "#Pnt" );
var idClr = charIDToTypeID( "Clr " );
var idRd = charIDToTypeID( "Rd  " );
var idGrn = charIDToTypeID( "Grn " );
var idBl = charIDToTypeID( "Bl  " );
var idRGBC = charIDToTypeID( "RGBC" );
var idcontentLayer = stringIDToTypeID( "contentLayer" );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );
var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );
    var desc41 = new ActionDescriptor();
        var ref12 = new ActionReference();
        ref12.putClass( idcontentLayer );
    desc41.putReference( charIDToTypeID( "null" ), ref12 );
        var desc42 = new ActionDescriptor();
            var desc43 = new ActionDescriptor();
            if (theColor != false) {
                var desc44 = new ActionDescriptor();
                desc44.putDouble( idRd, theColor[0] );
                desc44.putDouble( idGrn, theColor[1] );
                desc44.putDouble( idBl, theColor[2] );
            desc43.putObject( idClr, idRGBC, desc44 );
            };
        desc42.putObject( charIDToTypeID( "Type" ), idsolidColorLayer, desc43 );
        var desc45 = new ActionDescriptor();
            desc45.putUnitDouble( charIDToTypeID( "Top " ), idPxl, theBounds[1] );
            desc45.putUnitDouble( charIDToTypeID( "Left" ), idPxl, theBounds[0] );
            desc45.putUnitDouble( charIDToTypeID( "Btom" ), idPxl, theBounds[3] );
            desc45.putUnitDouble( charIDToTypeID( "Rght" ), idPxl, theBounds[2] );
        desc42.putObject( charIDToTypeID( "Shp " ), charIDToTypeID( "Elps" ), desc45 );
            var desc46 = new ActionDescriptor();
            desc46.putInteger( stringIDToTypeID( "strokeStyleVersion" ), 2 );
            if (strokeWidth == 0) {desc46.putBoolean( stringIDToTypeID( "strokeEnabled" ), false )}
            else {desc46.putBoolean( stringIDToTypeID( "strokeEnabled" ), true )};
      if (theColor == false) {desc46.putBoolean( stringIDToTypeID( "fillEnabled" ), false )}
      else {{desc46.putBoolean( stringIDToTypeID( "fillEnabled" ), true )}};
            desc46.putUnitDouble( stringIDToTypeID( "strokeStyleLineWidth" ), idPnt, strokeWidth );
            desc46.putUnitDouble( stringIDToTypeID( "strokeStyleLineDashOffset" ), idPnt, 0.000000 );
            desc46.putDouble( stringIDToTypeID( "strokeStyleMiterLimit" ), 100.000000 );
            desc46.putEnumerated( stringIDToTypeID( "strokeStyleLineCapType" ), stringIDToTypeID( "strokeStyleButtCap" ), stringIDToTypeID( "strokeStyleButtCap" ) );
            desc46.putEnumerated( idstrokeStyleLineJoinType, idstrokeStyleLineJoinType, stringIDToTypeID( "strokeStyleMiterJoin" ) );
            desc46.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, stringIDToTypeID( "strokeStyleAlignCenter" ) );//strokeStyleAlignOutside
            desc46.putBoolean( stringIDToTypeID( "strokeStyleScaleLock" ), false );
            desc46.putBoolean( stringIDToTypeID( "strokeStyleStrokeAdjust" ), false );
                var list3 = new ActionList();
            desc46.putList( stringIDToTypeID( "strokeStyleLineDashSet" ), list3 );
            desc46.putEnumerated( stringIDToTypeID( "strokeStyleBlendMode" ), charIDToTypeID( "BlnM" ), charIDToTypeID( "Nrml" ) );
            desc46.putUnitDouble( stringIDToTypeID( "strokeStyleOpacity" ), charIDToTypeID( "#Prc" ), 100.000000 );
                var desc47 = new ActionDescriptor();
                    var desc48 = new ActionDescriptor();
                    desc48.putDouble( idRd, strokeColor[0] );
                    desc48.putDouble( idGrn, strokeColor[1] );
                    desc48.putDouble( idBl, strokeColor[2] );
                desc47.putObject( idClr, idRGBC, desc48 );
            desc46.putObject( stringIDToTypeID( "strokeStyleContent" ), idsolidColorLayer, desc47 );
            desc46.putDouble( stringIDToTypeID( "strokeStyleResolution" ), 300 );
        desc42.putObject( idstrokeStyle, idstrokeStyle, desc46 );
    desc41.putObject( charIDToTypeID( "Usng" ), idcontentLayer, desc42 );
executeAction( charIDToTypeID( "Mk  " ), desc41, DialogModes.NO );
} catch (e) {alert ("fail")}
};
////// add text layer //////
function createTextLayer (thisText, thePoint, res) {
var docRef = activeDocument;
var myLayerRef = docRef.artLayers.add();
myLayerRef.kind = LayerKind.TEXT;
myLayerRef.name = thisText;
var myTextRef = myLayerRef.textItem;
myTextRef.kind = TextType.POINTTEXT;
myTextRef.size = 24 * 72 / res;
myTextRef.font = "Arial";
myTextRef.justification = Justification.CENTER;
//Set text colour in RGB values
var newColor = new SolidColor();
newColor.rgb.red = 0;
newColor.rgb.green = 0;
newColor.rgb.blue = 0;
myTextRef.color = newColor;
// set the position;
myTextRef.position = [thePoint[0], thePoint[1]];
//myTextRef.position = [thePoint[0] * 72 / res, thePoint[1] * 72 / res];
myLayerRef.blendMode = BlendMode.NORMAL;
myLayerRef.opacity = 100;
myTextRef.useAutoLeading = false;
myTextRef.leading = 0;		
myTextRef.contents = thisText;
return docRef.activeLayer
};

updated 2024-04-09

 

 

Translate
c.pfaffenbichler
Community Expert
Community Expert
Apr 3, 2024 2:09 PM UTC

Could you please provide sample files (one as is and the intended resulting file)? 

Translate
c.pfaffenbichler
Community Expert
Community Expert
Apr 2, 2024 11:17 AM UTC
c.pfaffenbichler
Community Expert
Community Expert
Mar 28, 2024 8:26 AM UTC

Are you talking about Spot Channels? 

Translate
Jani.A
Jani.AAuthor
Participating Frequently
Apr 2, 2024 8:47 AM UTC

hmmm, I don´t know 🙂 perhaps. 
I need the colors I am using in my design, to be printet out on a .pdf along with the design I have made. 
Like the image att. below, were the colors from the center design is shown individually with color numbers below each. 
I hope this makes sense 🙂

Translate
c.pfaffenbichler
Community Expert
Community Expert
Apr 2, 2024 8:53 AM UTC

Please post images on the Forum in a browser, but don’t include them in email-replies. 

What is the print process you are working for? 

Translate