Copy link to clipboard
Copied
Hello,
I am a bit of noob with scripting and code and I have searched the community before posting this but couldn't find a solution that worked.
I will be batch processing png images which have a single color to them. I need to extract that color and then apply effects to the images using the extracted color.
My question here is limited to the color extraction and getting the hex value in a variable. Please guide me with the same.
Thanks
Another possible solution, also using the histogram, would be to use the magic wand took to select a corner of the image. This should be white, according to your samples. Once the selection is made, inverse it, then get your histogram data. Now there should be just one spike in each of the channels.
Copy link to clipboard
Copied
Can you post an example of the image file? Is the color a swatch in the photo or is the photo just one tone?
Copy link to clipboard
Copied
Thanks for your reply. Here are some of the sample images. These are png files and one tone. Color picker cannot be used as I have to process large number of files and also picking color from a specific pixel location wont work as the image might be empty in the defined pixel location.
Copy link to clipboard
Copied
You can probably get the color by using the histogram info. By getting the histogram figures and creating a loop to find which values have the greatest numbers, you can get the color. Obviously the rgb values for 255 will be high with the white, but there should be secondary spikes in the numbers. If there are no second spikes, you can assume that one of the channels also has a value of 255, like solid red.
Copy link to clipboard
Copied
Another possible solution, also using the histogram, would be to use the magic wand took to select a corner of the image. This should be white, according to your samples. Once the selection is made, inverse it, then get your histogram data. Now there should be just one spike in each of the channels.
Copy link to clipboard
Copied
Bonjour
You can select the bottom of the image with the function selectColorRange () - HERE
Then reverse the selection and take its coordinates
then use the ColorSamplers method on a point close to the color - modifying it if the color is that of the bottom
Copy link to clipboard
Copied
Thanks you I was able to achieve the desired result with the solution you provided
Copy link to clipboard
Copied