Skip to content

Instantly share code, notes, and snippets.

@ten-A
Created July 6, 2016 06:12
Show Gist options
  • Save ten-A/e0119a9fe9649bfe40029b743c993b12 to your computer and use it in GitHub Desktop.
Save ten-A/e0119a9fe9649bfe40029b743c993b12 to your computer and use it in GitHub Desktop.
Retrieve layers color value.
//Need to include stdlibs in xtools. You can reference below link.
//http://ps-scripts.sourceforge.net/xtools.html
#include "stdlib.js"
var desc = Stdlib.getLayerDescriptor(
app.activeDocument,
app.activeDocument.activeLayer
);
var adjs = desc.getList(cTID('Adjs'));
var clrDesc = adjs.getObjectValue(0);
var color= clrDesc.getObjectValue(cTID('Clr '));
var r = Math.round(color.getDouble(cTID('Rd ')));
var g = Math.round(color.getDouble(cTID('Grn ')));
var b = Math.round(color.getDouble(cTID('Bl ')));
alert(r+" "+g+" "+b);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment