Skip to main content
Participant
February 15, 2016
Answered

RGB to HSB (or HSL)

  • February 15, 2016
  • 1 reply
  • 1444 views

Hello,

I need to compare one color with array of other colors to get the closet color from the array.

the color I have is in CMYK numbers.

I was comparing the cmyk and found the picked one giving me the totally different color.

And it seems i need to use either HSL (HSB) or LAB color format to get the same color in different brightness or saturation.

Can  someone help me on this?

Current coding is based on javascript and comparing the CMYK numbers.

Could anyone revise this or let me know how to convert the CMYK color to LAB or HSB(HSL) color?

"getCols" is the function that comparing the color.

Files can be found from "Dropbox - color comparing"

To test, open "1B trimmed_rev2.ai" and run "PMStoDT using HSB.jsx" and select "DTcolor-NAME.csv" and then select "DTcolor-CMYK.csv".

Thank you.

This topic has been closed for replies.
Correct answer CarlosCanto

I'm not sure if this will help or if the conversion is accurate, here's how to convert to LAB

var labcolor = app.convertSampleColor(ImageColorSpace.CMYK, [1,0,0,0], ImageColorSpace.LAB, ColorConvertPurpose.defaultpurpose);

$.writeln(labcolor); // 99.2248382568359,-1.24514007568359,-1.51751708984375

1 reply

CarlosCanto
Community Expert
CarlosCantoCommunity ExpertCorrect answer
Community Expert
February 15, 2016

I'm not sure if this will help or if the conversion is accurate, here's how to convert to LAB

var labcolor = app.convertSampleColor(ImageColorSpace.CMYK, [1,0,0,0], ImageColorSpace.LAB, ColorConvertPurpose.defaultpurpose);

$.writeln(labcolor); // 99.2248382568359,-1.24514007568359,-1.51751708984375

sdfasgdgAuthor
Participant
February 15, 2016

It works.

Thank you!