Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe Photoshop Photoshop scripting: Need to convert hex color to nearest Pantone, or utilize existing webservice and feed data back to Photoshop

  • Photoshop scripting: Need to convert hex color to nearest Pantone, or utilize existing webservice and feed data back to Photoshop

    Posted by Colin James on June 26, 2015 at 12:30 am

    Hey all,

    I need a script that if I have a hex color value, I can return a string of the nearest Pantone solid coated color name.

    Photoshop (I’m using CS6 still )does this manually through the UI if I am in the color picker and then click on Color Libraries, it’ll select the closest Pantone color. I just can’t figure out how to do this part via scripting as it seems to be a blackbox, and actions just pick the color that I already had.

    If there is no way to do this through scripting natively in photoshop, is it possible to have the script fill in the form data here: https://www.netfront.fr/Services/rgb2pantone/ or here: https://rgb.to/ and return the result back to photoshop?

    Thanks for any suggestions!

    Blur Studio

    Colin James replied 11 years, 2 months ago 1 Member · 1 Reply
  • 1 Reply
  • Colin James

    July 2, 2015 at 5:47 pm

    Just following up because I found a solution and hopefully someone who is googling how to do this in the future might benefit.

    Basically what I ended up doing was the following: I used this script ( https://www.tonton-pixel.com/blog/scripts/utility-scripts/parse-color-book-file/%5B1%5D ) to turn the specific Pantone color book I needed into a JSON file.

    Then I used this https://www.tonton-pixel.com/blog/json-photoshop-scripting/json-action-manager/%5B2%5D JSON parser for photoshop that the same dude wrote to bring in the color book data into photoshop’s javascript as an object that I could step through. Be warned, while the JSON file that the colorbook parser spits out is valid json, i had to get rid of a lot of the spaces, carriage returns and some of the earlier entries ( only needed the color data anyway ) for it not to kick up an error when being parsed.

    Then I #included this script https://www.rags-int-inc.com/PhotoTechStuff/ColorCalculator/%5B3%5D and used its RGB > to lab color space conversion function. Then I used the delta-e 2k color comparison forumla function ( requires lab color space because its a perceptual match ( which is better )). I kept an array of the deltaE results and found the smallest one, then looked up which arrayvalue/color that was associated with and viola there is my pantone color. that’s the basic gist.

    Saved myself quite a bit of money not having to buy fashion industry plugins/software ( over priced and terrible… ).

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy