I have a folder of 300+ profile skintones that I must sort by color from light tones to dark tone. I can create an action to get the average colors for each of the skintones, but I won’t be able to rename the file automatically to match each color to identifies with.
Is it possible to create a script that will find the average color (of the whole photo; I usually just Filter>Blur>Average the layer) for each image in the folder and then save the new image with the RGB or Hex name of the average color added before the original file name?
EX: After the script Filter>Blur>Average the layer. The average color for skintone01.jpg is #ad8475 so it will rename the file to ad8475-skintone01.jpg
Also, I’m not sure if this is possible, but is there a way to arrange all the layers in accordance to its average color using script. I don’t think it could but figure since we’re on that topic, might as well get it out there.
EDIT: I just tested a few of the photos and found that sorting by HEX is not ideal as Windows sort the hex code in a weird order. So far, I found that sorting it by RGB number is ideal as long as there is spaces between all three numbers.
EX: If average color RGB is 110 73 58, then the script will name the new file “110 73 58 skintone01.jpg” and not “1107358 skintone01.jpg”. Again, this is due to how Windows sort the files.
**Bascially, this is what I want to do with the script for each photos in the folder:
- Duplicate Layer
- Filter > Blur > Average
- Copy RGB Values of current layer
- Turn current layer (one with the average color) invisible
- Save image with RGB values before the original filename (with a space between each RBG value).**
2
Answers
Thank you so much, Ghoul Fool!
I played around with your script along with some research and managed to fix the error Photoshop thew at me. I also made some tweaks to my liking. This is the resulting codes I'm using:
All I did was make the "blurred" layer active before averaging it, then change the coding for Copying RGB Value to fit the values from sampling code. Then I added the codes so that it will round the result up to 3 decimal points.
After I tried to see if I can get the script to save all new image to a new folder, but couldn't figured out how. LOL. But at least I got it working.
Thank you so much for your help. I wouldn't be able to to this without you and would probably be sitting in front of my computer for hours. :D
Okay here’s the what you need:
I’m doing this blind, should work though.