0

I have a list of colors in #XXXXXX format. How can I convert this list into a swatch (aco/ase) file? If it's not possible I'll settle for converting to an image.

Any help would be awesome.

Thank you.

1
  • The file format is rather simple you could easily dump one in python.
    – joojaa
    Jan 15 at 6:34
3

Plain text appears to be a stumbling block due to aco/ase files being binary. Over the years there's been some scripts developed to convert things like .csv files to swatches, but most of those resources are hard to find any more (at least for me). Lots of dead links and empty rabbit holes. They are at the Adobe community site, but since Adobe changed from "forum.adobe" to "community.adobe" they are very hard to find.

However, CSS files are not a problem using current Photoshop versions.
(This might also work for other Adobe apps. I never bother trying.)

So merely edit the text file so it resembles a CSS (Cascading Style Sheet) file in a minor way.

I took a simple list if hex colors...

#ff0000
#ff0099
#ff9900
#aaee33

.. and merely added a closing CSS bracket to the end of the list...

#ff0000
#ff0099
#ff9900
#aaee33
}

After adding the bracket, save the file with a .css suffix.

Tested, you only need the last, closing, bracket. You don't even need an opening bracket or any other CSS markup. Although full CSS markup will also work.

Then using Photoshop ... choose Load Swatches from the Swatches Panel Menu.
Navigate to, and open, your .css file.
Or use Replace Swatches to have only the new swatches in the panel.

enter image description here

All the the hex colors in the .css file will be seen and loaded as swatches.


Note: Many CSS color declarations work, from 3 digit hex values to rgb/rgba to hsl/hsla values (the [a/alpha] is ignored). Even if a color declaration is commented out in CSS, Photoshop will see it. In fact, Photoshop will convert RGB color declarations to hex numbers. The only things which will not work are "names" of colors and hwb color declarations.

enter image description here

enter image description here

It's fairly forgiving. You don't even need to separate colors in any way...

enter image description here

As long as that closing bracket is present it'll work.


From here, you can save the file to .ase or .aco formats using the Photoshop Swatches Panel Menu.


Note: If you have CSS files from a web site... you can merely load that CSS file.... Photoshop will search for, and load, all unique color reference in the CSS file. Pairing down the CSS file to only color references is not required.

7
  • 1
    +1 If there are a rather lot of colors, instead of "next-line+paste", then a find+replace would work (find: # replace with: ;} a: { #). EOL characters are not required for CSS so this ought to work (manually fix the first instance by removing leading ;}
    – Yorik
    Jan 13 at 22:35
  • @Yorik I agree. I use BBEdit and it has an option to merely add prefixes/suffixes to each line. Takes a split second regardless of the length of the list. If comma separated, find/replace would work wonderfully. And you're right, even find replace on the # would work great (added to answer).
    – Scott
    Jan 13 at 22:37
  • This is awesome! Thank you so much for the reply. Is there a way to specify a name of each swatch as well so when it's read in to Photoshop the swatches are named properly?
    – Jay
    Jan 13 at 23:45
  • Hi @Jay I don't think so. CSS offers no direct ability to name color values - I'm afraid you need scripting for that... in which case, there's that Adobe rabbit hole.There are scripts at the Adobe community site, but I had a very hard time trying to find anything which is viable today. You may have better luck -- community.adobe.com/t5/illustrator-discussions/… -- community.adobe.com/t5/illustrator-discussions/…
    – Scott
    Jan 14 at 1:33
  • For me.. I'd just rename the swatches in Photoshop. Chances are that'll take MUCH less time than finding a script which will work. (Unless, of course, this is something you need with great regularity)
    – Scott
    Jan 14 at 1:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.