Convert PDF to grayscale using GhostScript

[UPDATE] Huge caveat! While this is really meant to deal with RGB documents or objects, it does also convert CMYK and spot colors to grayscale. Unfortunately spot colors remain as separate plates that retain their name. This results in them being printed in color though on screen they appear gray. At least the colors (Pantone) and printer I tested on took spot channels and ripped them according to what they are named. If your printer does not have it’s own rendering library that matches your spot color names then I’m guessing they will print as grayscale.

It is possible to rasterize the art, which results in a pure grayscale, but you need such a high resolution even a simple business card with type and line art increases in size at least 30 times. I knew this was all too easy…

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 MacPorts.org. 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

(*
http://strawhousepig.net/
*)

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

on open the_files
make_it_gray(the_files)
end open

on make_it_gray(the_files)
repeat with _file in the_files
try
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 -o " & 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 *