What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Action to get hex codes of images?


Fatback

New Member
Messages
4
Likes
1
Hi everyone

I have an interesting puzzle to solve.... not sure if this is even possible.

What I have is a bunch of image files, and I need to compile a list of the hex codes of the color used in those files. Is there a way to create an action that finds the hex code and then pastes it somewhere (could be a PSD file, doesn't matter) where I can later pull the info to put in a spreadsheet?

I couldn't think of a way to do this, any suggestions would be much appreciated!! :)
 
Hello and welcome to PSG.

As far as I know this is not really possible due to the fact that you would have to open the color picker which could be done with an action, but you would have to manually (with the mouse) chose the exact spot to be sampled. If you use the eyedropper during record, it only records the color value you selected during the record and will use that for every image, instead of recording the act of sampling a specific point. You would have to set up a stop for the user interaction after you open the color picker.

If your going to sample each image, here's a nifty little program I use all the time: http://sipapp.io/

I'm not certain of whether or not a script could be programmed to do this or perhaps a method using variables.
 
The more I read, it looks like it may be possible with a script...............that's out of my skill set!

But we do have several members who are very knowledgeable in this matter, it's just going to take some patience waiting for them to respond. Good luck.
 
Here's what I would do:

a) bulk convert all the images to either BMP or TIF files without any compression;

b) figure out the offset (in bytes) from the start of the file at which the RGB data for the pixel of interest is located;

c) use any of several standard programming utilities (eg, AWK, Grep, etc.) to go to that offset, read the appropriate number of bytes in the file, and then append (aka, concatenate) them in an appropriate, easy to read format to the end of a delimited ASCII file (eg, a comma delimited file, CSV, or whatever);

d) Use the looping facility in the utility you are using to chew its way through all the files in that directory (and possibly subdirectories).

From there, it's trivial to have Excel import the text file into a spreadsheet.

If you happen to know Matlab (and have a oopy available to you), it would only take a few lines of code to do what you requested.

There are a huge number of other ways to do this, but IMHO, if you know any programming at all, Photoshop just isn't the right tool for this job.

Tom M

PS - I must say that you have my curiosity peaked. May I ask what this is for?
 
I thank you for that suggestion, but this is honestly way over my head, and honestly there are only about 100 files and I think I'll just tough it out and do it manually. By the time I figure out a shortcut, I could of done it myself by hand! :)

This is for custom products I sell on amazon. Each image file represents a product and they all have different color fonts to use, which I need the hex code for so I can tell the amazon system what color to use.

Thanks again for the time and help everyone. I appreciate it! :)
 
Last edited:
I understand completely! Sometimes, when you have a job to do, you are not likely ever to need to do it again, and it's not too repetitive (i.e., only 100 files), doing it manually is exactly what you should do because it gets the job done in the shortest amount of time.

Good luck with your work.

Tom M
 
...I actually am sampling the same exact spot for each image.
...and what would be the location of said 'spot'...? (Pixel coords).

If its the same pixel on every file then I may have [EDIT: do have] a script for you.

Regards.
MrToM.
 
Last edited:
You could save your image in RAW format(Non-Interleaved). Color values in the raw file we'll be organized as following: (R,G,B), (R,G,B), (R,G,B), ... , i.e., three bytes for each pixel. Then you can use simple script in Excel to convert color byte values to their text presentation.
 
For 100 images and all you want is the hex code, manual is the way to go and you would have been done before reading and thinking about all the posts in this thread in my opinion.

Here is what I would do.

Make sure all the images are in or converted to sRGB so the hex codes max sense to amazon.

Create a color sampler point in the position you want (assuming all images are the same size and same position for the sample otherwise it needs to be positioned manually)

May sure the color sampler is set to the size you need (e.g. single pixel or average out over several pixels)

Turn on the info panel and set the color sampler point to Web Colors. Putting the hex code for R then G then B in order is the hex code you want

One at a time paste or embed each image into the psd file to preserve the sampler point position and read the hex code in the info panel for each

Done

Just my opinion of course

John Wheeler
 
Last edited:
...you would have been done before reading and thinking about all the posts...
ALL the posts?

I offered a scripted solution, (which, BTW, more or less does the same as you describe), some 9 hours ago.....but in order for it to work as they require I need the requested additional info from the OP.

Regards.
MrToM.
 
Last edited:
Oh no no no no no......none taken....I was just agreeing with you that it could have been sorted several hours earlier had the OP have stuck around a little while longer.

Half an hour earlier I may have caught them but never mind.

It was early...sorry if it sounded like an annoyance, it wasn't meant to.....mornings and I have never got on well.

Regards.
MrToM.
 

Back
Top