Convert PDF to grayscale using GhostScript

This script / app / droplet will convert a PDF or PostScript (.ps) document from whatever colorspace it lives in to grayscale. Has not been thoroughly tested. I mean, I ran it against a couple of files. One to work out the gs command, the other to test if it actually made a grayscale duplicate. That file was generated by MS Word so was of course RGB. The converted document was in fact true grayscale. I would say it converted to what you would get if you used a gray gamma 2.2 profile.

Unfortunately it does not alter the appearance of [registration] colors. This would really have made my life even easier. Maybe there is a way, I didn’t really look into it.

This script relies on the GhostScript installation from If you already have GhostScript installed from a different source be sure to update the do shell script line below.

Niceties include being a droplet, accepting multiple items, and checking those items for a .pdf or .ps extension. It *should* ignore other files. I would rather have used the kind attribute, but after finding a third figured it’s anyone’s guess what string softwares A though Z place there. Also including a generic icon to use in the application package, should you desire to save this script as such. I did try a cute little rainbow icon, but it quickly became impossible to distinguish.

Convert GS.icns


on run
  tell application "Finder"
      set _files to (selection as list)
      my make_it_gray(_files)
    end try
  end tell
end run

on open the_files
end open

on make_it_gray(the_files)
  repeat with _file in the_files
      set finfo to info for (_file as alias)
      if name extension of finfo is in {"pdf", "ps"} then
        set source_path to quoted form of POSIX path of (_file as alias)
        set target_path to quoted form of (POSIX path of (folder of _file as alias) & "gs_" & name of finfo)
        do shell script "/opt/local/bin/gs -sDEVICE=pdfwrite -dProcessColorModel=/DeviceGray -dColorConversionStrategy=/Gray -dDevicecGrayToK=true -dOverrideICC -dNOPAUSE -dBATCH -sOutputFile=" & target_path & " -f " & source_path
      end if
    on error theErr
      if theErr is not "User canceled." then display dialog theErr
    end try
  end repeat
end make_it_gray

Leave a Reply

Your email address will not be published. Required fields are marked *