{"id":856,"date":"2020-07-30T15:17:42","date_gmt":"2020-07-30T22:17:42","guid":{"rendered":"http:\/\/10.0.1.201\/?p=856"},"modified":"2025-12-01T11:47:55","modified_gmt":"2025-12-01T18:47:55","slug":"convert-pdf-to-grayscale-using-ghostscript","status":"publish","type":"post","link":"https:\/\/strawhousepig.net\/wordpress\/2020\/07\/30\/convert-pdf-to-grayscale-using-ghostscript\/","title":{"rendered":"Convert PDF to grayscale using GhostScript"},"content":{"rendered":"\n<p><ins datetime=\"2020-08-19T06:12:32+00:00\">[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&#8217;s own rendering library that matches your spot color names then I&#8217;m guessing they will print as grayscale.<\/ins><\/p>\n\n\n\n<p><ins datetime=\"2020-08-19T06:27:12+00:00\">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&#8230;<\/ins><\/p>\n\n\n\n<p>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 <code>gs<\/code> 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.<br>\n<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>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&#8217;t really look into it.<\/p>\n\n\n\n<p>This script relies on the <strong>GhostScript<\/strong> installation from <a href=\"https:\/\/www.macports.org\/\">MacPorts.org<\/a>. If you already have GhostScript installed from a different source be sure to update the <code>do shell script<\/code> line below.<\/p>\n\n\n\n<p>Niceties include being a droplet, accepting multiple items, and checking those items for a <strong>.pdf<\/strong> or <strong>.ps<\/strong> extension. It *should* ignore other files. I would rather have used the <em>kind<\/em> attribute, but after finding a third figured it&#8217;s anyone&#8217;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 <a href=\"http:\/\/strawhousepig.net\/wordpress\/wp-content\/uploads\/2020\/07\/Convert-GS-512.png\">cute little rainbow<\/a> icon, but it quickly became impossible to distinguish.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"128\" height=\"128\" src=\"https:\/\/strawhousepig.net\/wordpress\/wp-content\/uploads\/2020\/07\/Convert-to-grayscale-using-Ghostscript.png\" alt=\"\" class=\"wp-image-1078\" style=\"width:130px;height:auto\"\/><\/figure>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-547903c7-5728-4ed3-9981-b70dc9098d2d\" href=\"https:\/\/strawhousepig.net\/wordpress\/wp-content\/uploads\/2020\/07\/Convert-to-grayscale-using-Ghostscript.icns_.zip\">Convert to grayscale using Ghostscript.icns<\/a><a href=\"https:\/\/strawhousepig.net\/wordpress\/wp-content\/uploads\/2020\/07\/Convert-to-grayscale-using-Ghostscript.icns_.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-547903c7-5728-4ed3-9981-b70dc9098d2d\">Download<\/a><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>on run\n\ttell application \"Finder\"\n\t\ttry\n\t\t\tset _files to (selection as list)\n\t\t\tmy make_it_gray(_files)\n\t\tend try\n\tend tell\nend run\n\non open the_files\n\tmake_it_gray(the_files)\nend open\n\non make_it_gray(the_files)\n\trepeat with _file in the_files\n\t\ttry\n\t\t\tset finfo to info for (_file as alias)\n\t\t\tif name extension of finfo is in {\"pdf\", \"ps\"} then\n\t\t\t\tset source_path to quoted form of POSIX path of (_file as alias)\n\t\t\t\tset _name to (characters 1 thru -((offset of \".\" in (reverse of items of name of finfo as string)) + 1) of name of finfo as string) &amp; \"_gs.pdf\"\n\t\t\t\tset target_path to quoted form of (POSIX path of (folder of _file as alias) &amp; _name)\n\t\t\t\tdo shell script \"\/opt\/local\/bin\/gs -sDEVICE=pdfwrite -dProcessColorModel=\/DeviceGray -dColorConversionStrategy=\/Gray -dDevicecGrayToK=true -dOverrideICC -dNOPAUSE -dBATCH -sOutputFile=\" &amp; target_path &amp; \" -f \" &amp; source_path\n\t\t\tend if\n\t\ton error theErr\n\t\t\tif theErr is not \"User canceled.\" then display dialog theErr\n\t\tend try\n\tend repeat\nend make_it_gray<code>\n<\/code><\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[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) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10,12,24,28],"class_list":["post-856","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-applescript-2","tag-color","tag-macos","tag-os-x"],"_links":{"self":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts\/856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/comments?post=856"}],"version-history":[{"count":2,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts\/856\/revisions"}],"predecessor-version":[{"id":1080,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts\/856\/revisions\/1080"}],"wp:attachment":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/media?parent=856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/categories?post=856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/tags?post=856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}