can automator check if a file is CMYK or RGB?

Dear all,


I would like to know if there is a way i can let Automator make a script where it checks if a file is RGB or CMYK.

on a daily base, i need to send images over in CMYK, but sometimes i forget to convert it.


Now i was wondering if it is possible to let automator can show me in the finder if a file is CMYK or RGB.

I know it is possible in file info (See screenshot) but i was hoping there is another way of showing this. For example by making the image red..


Hope my question is clear enough ;-)


User uploaded file

Posted on Jan 16, 2018 7:17 AM

Reply
Question marked as Top-ranking reply

Posted on Jan 16, 2018 2:58 PM

That command will work on the Terminal command-line, or in an Automator solution as offered below. The only thing you can do to an image in the Finder is to assign a custom color tag to it such as "RGB", "CMYK", etc in the Finder Preferences. Then in Spotlight, you can search tag:CMYK, or if in Germany, kMDItemFSLabel:CMYK .


You can make an Automator Service that allows you to select the image files in the Finder. You then press a unique assigned keyboard shortcut to the Service item, and the result would be a pop-up dialog:

User uploaded file

The output facilities in AppleScript are quite limited, so longer filenames will not scroll, but do wrap, messing up the display.


  1. Launch Automator. Dock : Launchpad : Other : Automator

    Choose Service, and then click Choose

  2. Drag and Drop the Run AppleScript action onto the larger workflow window
    1. Sierra and High Sierra

      Automator Library

    2. Earlier OS X

      Utilities Library

  3. Service receives selected Image files in Finder. Output replaces selected text remains unchecked.
  4. In the Run AppleScript action, you will replace the line (* Your script goes here *) with the copy/pasted AppleScript in the Code below.
    1. Click the compile button in the action
    2. File menu save and name it Image Color Space, with no file extension. You can always open this as a Recent Item in Automator if you need to change something.
  5. Quit Automator.
  6. In System Preferences : Keyboard panel : Shortcuts : Services, find your service name, and on the right side of the name click to add your unique keyboard shortcut. Be careful not to use any that are already in use by Finder.
  7. Quit System Preferences.
  8. Select a file or files in the Finder, and then apply your special keystroke. You should see the above dialog with your file information.


Code (copy/paste below this line)


use scripting additions


on run {input, parameters}

tell application "Finder"

launch

if (count of input) > 0 then

set sel to input as alias list

else

return

end if

set report to {}

repeat with afile in sel

set imgfile to afile'sPOSIX path

set cspace to (do shell script "sips -g space " & imgfile & " | awk '/space/ {print $2=$2}'") as text

if cspace is "RGB" then

set spacing to " "

else if cspace is "Gray" then

set spacing to " "

else if cspace is "CMYK" then

set spacing to " "

end if

copy (cspace & spacing & (name of afile)) as text to the end of report

end repeat

end tell

-- show a list of color space and associated filenames

set {TID, AppleScript'stext item delimiters} to {AppleScript'stext item delimiters, return}

display dialog (items of report) as text with title "Image Colorspace Report"

set AppleScript'stext item delimiters to TID

return input

end run

3 replies
Question marked as Top-ranking reply

Jan 16, 2018 2:58 PM in response to Maklovin

That command will work on the Terminal command-line, or in an Automator solution as offered below. The only thing you can do to an image in the Finder is to assign a custom color tag to it such as "RGB", "CMYK", etc in the Finder Preferences. Then in Spotlight, you can search tag:CMYK, or if in Germany, kMDItemFSLabel:CMYK .


You can make an Automator Service that allows you to select the image files in the Finder. You then press a unique assigned keyboard shortcut to the Service item, and the result would be a pop-up dialog:

User uploaded file

The output facilities in AppleScript are quite limited, so longer filenames will not scroll, but do wrap, messing up the display.


  1. Launch Automator. Dock : Launchpad : Other : Automator

    Choose Service, and then click Choose

  2. Drag and Drop the Run AppleScript action onto the larger workflow window
    1. Sierra and High Sierra

      Automator Library

    2. Earlier OS X

      Utilities Library

  3. Service receives selected Image files in Finder. Output replaces selected text remains unchecked.
  4. In the Run AppleScript action, you will replace the line (* Your script goes here *) with the copy/pasted AppleScript in the Code below.
    1. Click the compile button in the action
    2. File menu save and name it Image Color Space, with no file extension. You can always open this as a Recent Item in Automator if you need to change something.
  5. Quit Automator.
  6. In System Preferences : Keyboard panel : Shortcuts : Services, find your service name, and on the right side of the name click to add your unique keyboard shortcut. Be careful not to use any that are already in use by Finder.
  7. Quit System Preferences.
  8. Select a file or files in the Finder, and then apply your special keystroke. You should see the above dialog with your file information.


Code (copy/paste below this line)


use scripting additions


on run {input, parameters}

tell application "Finder"

launch

if (count of input) > 0 then

set sel to input as alias list

else

return

end if

set report to {}

repeat with afile in sel

set imgfile to afile'sPOSIX path

set cspace to (do shell script "sips -g space " & imgfile & " | awk '/space/ {print $2=$2}'") as text

if cspace is "RGB" then

set spacing to " "

else if cspace is "Gray" then

set spacing to " "

else if cspace is "CMYK" then

set spacing to " "

end if

copy (cspace & spacing & (name of afile)) as text to the end of report

end repeat

end tell

-- show a list of color space and associated filenames

set {TID, AppleScript'stext item delimiters} to {AppleScript'stext item delimiters, return}

display dialog (items of report) as text with title "Image Colorspace Report"

set AppleScript'stext item delimiters to TID

return input

end run

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

can automator check if a file is CMYK or RGB?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.