Advertisement


How do I create color swatch for Photoshop from a list of RGB values?


Question

I have a list of colors as RRR GGG BBB in a text file and I need to use only those colors to create my images. I'd like to be able to load those colors to Photoshop's color palette (swatch). Is there a way to automate swatch creation process from within Photoshop or some other way to create swatch file from a list of colors as a text file?

(P.S. there should be tags such as Palette and Swatch)

Upd: I have lots of colors in the list and my list is not the only one, users are supposed to have easy way to convert the list into Photoshop compatible swatch file so we can all start drawing right away.

2014/02/19
1
4
2/19/2014 1:43:00 PM

Accepted Answer

ASE is Adobe Swatch Exchange Format. Unfortunately, it is a binary format, but fortunately, people have made source code available for ASE encoding scripts. See for instance ( http://blog.soulwire.co.uk/code/actionscript-3/as3-ase-adobe-swatch-exchange-encoder ).

Adobe may support ACBL format (XML) or ACF format (text), but they appear to be legacy formats and do not show up in the "load swatches" file types options.

This doesn't always mean they aren't supported, but you will need to get your file dialog to ignore the file-type filter:

windows, type *.* in the file name box and hit enter

2012/10/02
2
10/2/2012 5:54:00 PM

I'd create a small web page and then take a screen grab. You'll end up with a bitmap image you can place on a layer. From there you can sample the colours and use them in your design.

If your list looks something like this:

0 0 0
0 0 255
0 255 0
255 0 0

Some clever find/replacing should get you what's needed to create a web page. Depending on the exact characters in the document, you should hopefully be able to get the document into this format. Finding spaces and replacing with ", " should give you this:

0, 0, 0
0, 0, 255
0, 255, 0
255, 0, 0

You could then find the return character, and replace with something like this:

);">&nbsp;</div> *return character*
<div style="width:100px;height:100px;float:left;background:rgb(

So you end up with:

0, 0, 0);">&nbsp;</div>
<div style="width:100px;height:100px;float:left;background:rgb(0, 0, 255);">&nbsp;</div>
<div style="width:100px;height:100px;float:left;background:rgb(0, 255, 0);">&nbsp;</div>
<div style="width:100px;height:100px;float:left;background:rgb(255, 0, 0)

Which means you just need to add a little bit of HTML to the start and end of the document to have a webpage you can display and screen grab.

<!DOCTYPE html>
<html lang="en-us">
<body>
<div style="width:100px;height:100px;float:left;background:rgb(0, 0, 0);">&nbsp;</div>
<div style="width:100px;height:100px;float:left;background:rgb(0, 0, 255);">&nbsp;</div>
<div style="width:100px;height:100px;float:left;background:rgb(0, 255, 0);">&nbsp;</div>
<div style="width:100px;height:100px;float:left;background:rgb(255, 0, 0);">&nbsp;</div>
</body>
</html>

Make sure the browser you use displays the colours in a way that matches your raw colour values though. You can test this by checking a few of the colours — see if they match the values you initially entered.

You could even save the find and replace strings and process future files in the same way.

If you really need the result to be a Photoshop swatch file, you might need to enlist a friendly developer to create a small script to build the files you're after.


Another option is scripting Photoshop to automate adding the swatches directly, rather than building a swatch file. The PS-Scripts forum might be a good place to look for help.

http://www.ps-scripts.com/bb/viewtopic.php?t=842

2012/10/02