Trying to create an action to create a swatch from HEX code in clipboard
Copy link to clipboard
Copied
I need to build an action for my team to be able to create a swatch on a new layer using a HEX code we copied from text outside of photoshop.
Some background info, we retouch clothing for an international line, edit about a few hundred images a day. One of our responsibilites is making sure the color in the photo is accurate to the product, but now we're working from home and rely on HEX codes provided by the photographer to color correct to.
It sounded simple enough to do at first, but once I got into it, I realized the action process when changing a primary color seems to have no way to record "paste" and just records setting the color to whatever test HEX code I'm using. Is there a way around this? Or another way to create a swatch from whatever HEX code we currently have copied?
Explore related tutorials & articles
Copy link to clipboard
Copied
It does not sound simple. There is no way you could record an action to do that. You should be able to program a Photoshop Script to add a new layer and fill a square section of it with a hex color. There is no interface to drop a hex code on Photoshop. You can drop files onto Photoshop. So if you drop a Photoshop script file on Photoshop Photoshop will run it. The script could have the Hex code coded in it or get it some way, like with a user prompt. Where the user could type or Paste in the hex code. The script could be run from a shortcut or an action.
Copy link to clipboard
Copied
What OS are you using? You can get the clipboard contents via AppleScript. This would set the foreground color to a valid hex value on the clipboard:
tell application id "com.adobe.photoshop"
set cb to the clipboard as string
try
set foreground color to {class:RGB hex color, hex value:cb}
end try
end tell
Copy link to clipboard
Copied
I can't help you with your action but one word of warning for your process. Make sure the photographer specifying the Hex code and your retouchers using that code, are using the Hex code in the same colour space. Hex codes are simply base sixteen representations of the base ten RGB values and as such, the same Hex code represents different colours in different colour spaces (e.g. sRGB, Adobe RGB, Pro Photo etc). Or conversely the same colour requires different Hex codes in different colour spaces.
Dave
Copy link to clipboard
Copied
With extendscript you can copy text to clipboard, but not from. So tell us where the HEX code is copied from and if for example that's text file, the script can read easily its content to apply it as the whole or specified part.
Copy link to clipboard
Copied
What if you put a step in your action to open the Color Picker where you could paste in the Hex code?
Like Edit>Fill>Color
One caveat is users would have to remember to click Color in order for the Color Picker to open.
Also remember to paste the Hex code as well.
Toggle the Fill Dialog step to On in the actions panel.
Copy link to clipboard
Copied
The following line of JavaScript code should open the colour picker with the hex field highlighted, ready to paste the clipboard contents:
app.showColorPicker();
Copy link to clipboard
Copied
The thing is they want to create a swatch to click the color in the image document is is what the customer wants the hex code they supplied. The thing is a hex code is a different color in different color spaces. I'm not sure the OP knows what they actually need to do or how a photographer could supply a hex color code for an image.

