LAB value - decimal or integer

Community Beginner ,
Apr 04, 2022 Apr 04, 2022

Copy link to clipboard

Copied

Hi, I noticed that you can't set an LAB colors to decimal values, but to my big surprise, when you read the LAB values with an illustrator script, it will give you the exact decimal value.

 

First, I wish that illustrator would support LAB with decimal point for much better accuracy.

 

Secondly, in the current situation, I want to read the L value, A and B of a swatch I have. using the code below, I will get a value of -15.67 for example, which I will need to round if I want illustrator to read it.

Do you have an idea how can I round it to the value of the document?

For example, if B value is -15.67, illustrator will show the swatch's B value as -15 and not -16. Therefore I need to round it using Math.ceil , and if it was a positive number, Math.floor.

 

I can do an if statemant that will do the proper rounding if value is above 0 or below 0, but what if it's between -1 and 1?  The swatch might show 0 but the code will say it's -0.6 or 0.6 and I wouldn't know what rounding command is needed.

 

The code I use:

 var destColorSpace = ImageColorSpace["LAB"];
    var outputColors = app.convertSampleColor(
      sourceSpace,
      colorComponents,
      destColorSpace,
      ColorConvertPurpose.previewpurpose
    );
    var l = Math.round(outputColors[0]), // grabs l value
        a = Math.floor(outputColors[1]), // grabs a value - rounds down for example
        b = outputColors[2]; // grabs b value - without rounding

alert(b) // output: -15.67
TOPICS
Bug , Feature request , Scripting

Views

105

Likes

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 Community Professional ,
Apr 04, 2022 Apr 04, 2022

Copy link to clipboard

Copied

I get -16 reading a lab value of -15.67

 

can you post the exact process you're following to try to replicate it?

Likes

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 Beginner ,
Apr 22, 2022 Apr 22, 2022

Copy link to clipboard

Copied

Try many more swatches with different color combinations.

 

I had a case of 15.67 for example showing up in Illustrator as 15 or 14 instead of 16.

 

I can't post the exact process or file, as it is protected data of a company.

Likes

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 Beginner ,
Apr 22, 2022 Apr 22, 2022

Copy link to clipboard

Copied

LATEST

I wrote another post about this issue with an example and more info:

https://community.adobe.com/t5/illustrator-discussions/no-way-to-grab-lab-values-using-illustrator-s...

Likes

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