Find Lab Color of Selected Object
var doc = app.activeDocument;
var sel = doc.selection;
var result= new LabColor();
function getColorValues ( color ) {
if ( color === undefined ) return undefined;
else if ( color.typename === 'CMYKColor' ) return [ color.cyan, color.magenta, color.yellow, color.black ];
else if ( color.typename === 'RGBColor' ) return [ color.red, color.green, color.blue ];
else if ( color.typename === 'LabColor' ) return [ color.l, color.a, color.b ];
else if ( color.typename === 'SpotColor' ) return getColorValues( color.spot.color );
else if ( color.typename === 'GrayColor' ) return [ color.gray ];
}
function translatetolab(objerenk) {
sourceColorSpace = ImageColorSpace.RGB;
destColorSpace = ImageColorSpace.LAB;
result= new LabColor().hostObjectDelegate;
result = app.convertSampleColor(ImageColorSpace.RGB, objerenk, ImageColorSpace.LAB, ColorConvertPurpose.defaultpurpose);
alert (result);
}
renk.red = sel[0].fillColor.red;
renk.green = sel[0].fillColor.green;
renk.blue= sel[0].fillColor.blue;
renkrgb = (getColorValues(renk));
translatetolab(renkrgb);
Hello I am trying to find lightness value of selected object's fill color. Above I tried to convert RGB color to LAB. But even my objects fill color is %100 black or white it shows an array like 0,-0,4,0,4 and also I am not sure if my way is correct may be there would be an easier way. Please note that I am still new to extendscript.
What I am exactly trying to do is operating objects depending their lightness values.
Thank you,
Best Regards.