• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How do I export a large number of swatch colors as their HEX values

New Here ,
Apr 13, 2023 Apr 13, 2023

Copy link to clipboard

Copied

I am helping a scientist use PS to analyse a specimen image. They want to select dozens of points and create a table of numbers identifying the colors (any way is fine: RGB, HEX, etc.). I can make swatches and click on individual colors then copy each one, but we have a lot of samples, so this isn't great. Is there would be a way to export swatches into a text file? Thanks!

TOPICS
Actions and scripting

Views

448

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 Expert ,
Apr 13, 2023 Apr 13, 2023

Copy link to clipboard

Copied

Is there would be a way to export swatches into a text file?

By @Kristen23994564c4c7

 

Not out of the box, but we never know what our volunteer scripters can come up with. I've edited your post and tagged it for scripting.

 

Jane

 

Votes

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 Expert ,
Apr 13, 2023 Apr 13, 2023

Copy link to clipboard

Copied

As Jane mentioned, a script could do this. A simple script's work flow could be like this:

User samples color point, then hits a hotkey to run a script that records the values to a text file that can be imported into a spread sheet. The script could be made to record the 10 saved color samplers, so the script would not have to be run after each sampling. 

Votes

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 Expert ,
Apr 13, 2023 Apr 13, 2023

Copy link to clipboard

Copied

LATEST

Here's a little script that will record color samplers, as I mentioned previously. It will record the samples to a file named colors.txt on your desktop, in a folder called "color samples." Make some color samples and run the script. If you want to add more to the file, clear the color samplers, with the clear all button in the menu bar, add more samples and run the script again. If you want to start over and make a new color sample file, either delete the current colors.txt file, or rename it to save it. Then start the process of setting sample points again.

 

This script will record RGB values, but can be changed to record HEX.

 

 

#target photoshop
var colorFolder = new Folder('~/desktop/color samples/')
var colorFile = new File('~/desktop/color samples/colors.txt')
if(!colorFolder.exists){colorFolder.create()}
var doc = activeDocument;

var colorList = '';
if(colorFile.exists){colorList = readFile (colorFile)};

for(i=0;i<doc.colorSamplers.length;i++){
    colorList += doc.colorSamplers[i].color.rgb.red +',' + doc.colorSamplers[i].color.rgb.green + ',' +doc.colorSamplers[i].color.rgb.blue + '\n'
    }

writeFile (colorFile, colorList)

function readFile(file) {
	if (!file.exists) {
		alert( "Cannot find file: " + deodeURI(file.absoluteURI));
		}
	else{
		file.encoding = "UTF8";
		file.lineFeed = "unix";
		file.open("r", "TEXT", "????");
		var str = file.read();
		file.close();

		return str;
		};
};

function writeFile(file,str) {

		file.encoding = "UTF8";
		file.open("w", "TEXT", "????");
		//unicode signature, this is UTF16 but will convert to UTF8 "EF BB BF"
		file.write("\uFEFF");
		file.lineFeed = "unix";
		file.write(str);
		file.close();
		
	};

 

Votes

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