Hi
I have a folder of random images that I want to seperate in to colour or black & white.
All the images will be rgb to start with, I’ll need to do this with applescript (or from within applescript) as it’s part of a bigger workflow.
I’ve had a search around but I really don’t know where to start with this one.
I’m thinking sample some points of the image and check the values?
many thanks
Shane
Hi. Unless there is a separate channel or an area that is intended to be a set dropper value for discrimination, there is no way to test your condition. An image that starts in the RGB color space is color, by definition”regardless of whether the image may appear to be achromatic.
Ok, so I’ve just done some tests and if the image is grey scale within a rgb colour mode all the values are equal. So if I run some random sample and test if all the value are equal, then the image could be black & white.
Do think this would be robust enough?
Nothing prevents a color image from having white, black, or gray values within it. 
ok, think I got this working.
Firstly this is not mission critical! It’s just a guide to help me find the majority of B&W images within a folder
Depending upon the time / accuracy, I can up the sample points for each image/
Just to re-cap this [should] stop sampling if it finds coloured pixels in an RGB image, however if it only finds neutral pixels eg. 255, 255, 255 or 64, 64, 64, then it continues as these valves tend to show that the image has no colour and therefore appear grey within a RGB environment / colour mode.
Any tips for speeding this up would be appreciated.
many thanks
Shane
tell application "Adobe Photoshop CC 2015"
tell current document
set w to width
set h to height
--
--
set w to w - 20
set h to h - 20
--
set myPrintColour to "BlackPrint"
--
set mySixthIncrementWidth to w / 10
set mySixthIncrementHeight to h / 10
--
--
set myWPosition to 10
set myHPosition to 10
set myColourSamples to {}
--
set myWgrid to 1
set myHgrid to 1
--
--
repeat with x from 1 to 99
--
set My_Sampler to make new color sampler with properties {class:color sampler, position:{myWPosition, myHPosition}}
set My_Values to color sampler color of My_Sampler
--
-- delay 1
--
delete My_Sampler
--
--
if (red of My_Values) = (blue of My_Values) then
if (red of My_Values) = (green of My_Values) then
set the end of myColourSamples to "Black"
end if
end if
if (red of My_Values) ≠(blue of My_Values) then
if (red of My_Values) ≠(green of My_Values) then
set the end of myColourSamples to "Colour"
end if
end if
--
--
if myWgrid is less than or equal to 10 then
set myWPosition to myWPosition + mySixthIncrementWidth
set myWgrid to myWgrid + 1
else
set myWPosition to 10
set myWgrid to 1
end if
if myWgrid is equal to 10 then
set myHPosition to myHPosition + mySixthIncrementHeight
set myHgrid to myHgrid + 1
set myWPosition to 10
set myWgrid to 1
end if
--
--
--log My_Values
--log item x of myColourSamples & return & return
if item x of myColourSamples is equal to "Colour" then
-- display dialog "It's colour!" giving up after 1
set myPrintColour to "ColourPrint"
exit repeat
end if
end repeat
log myPrintColour
end tell
end tell
Hi. Since you aren’t concerned with the potential unsoundness of the whole procedure, I can offer a shorter method that doesn’t require multiple sample points, but whether it proves faster depends on a lot of undeclared variables.
tell application "Adobe Photoshop CS3"'s document 1
filter art layer 1 using average
set values to (make color sampler with properties {position:{1, 1}})'s color sampler color's {red, green, blue}
close without saving
end tell
tell values to if item 1 = item 2 and item 1 = item 3 then "It's within the realm of possibility that this was once grayscale."