{"id":59,"date":"2015-08-06T13:15:48","date_gmt":"2015-08-06T11:15:48","guid":{"rendered":"https:\/\/kutila.fi\/?p=59"},"modified":"2015-12-22T21:23:10","modified_gmt":"2015-12-22T19:23:10","slug":"pdf-to-gray","status":"publish","type":"post","link":"https:\/\/kutila.fi\/wp\/pdf-to-gray\/","title":{"rendered":"Convert PDF to grayscale using Ghostscript"},"content":{"rendered":"<p>This is a Bash function I have in my <code>.bashrc<\/code>. This function uses Ghostscript (<code>gs<\/code>), which must be installed in the system.<\/p>\n<p><code><br \/>\n# Convert pdf to grayscale<br \/>\nfunction pdf2gray {<br \/>\n    gs \\<br \/>\n    -sDEVICE=pdfwrite \\<br \/>\n    -sProcessColorModel=DeviceGray \\<br \/>\n    -sColorConversionStrategy=Gray \\<br \/>\n    -dOverrideICC \\<br \/>\n    -f $1 \\<br \/>\n    -o $2<br \/>\n}<br \/>\n<\/code><\/p>\n<p>In this example a file called <code>abc.pdf<\/code> is converted to grayscale copy called <code>abc_gray.pdf<\/code>. The first argument is the input file and the second argument is the output file. <em>Note: My function doesn&#8217;t check if these are given or not.<\/em><\/p>\n<p><code><br \/>\npdf2gray abc.pdf abc_gray.pdf<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a Bash function I have in my .bashrc. This function uses Ghostscript (gs), which must be installed in the system. # Convert pdf to grayscale function pdf2gray { gs \\ -sDEVICE=pdfwrite \\ -sProcessColorModel=DeviceGray \\ -sColorConversionStrategy=Gray \\ -dOverrideICC \\ -f $1 \\ -o $2 } In this example a file called abc.pdf is converted [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11,10],"class_list":["post-59","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-ghostscript","tag-pdf"],"_links":{"self":[{"href":"https:\/\/kutila.fi\/wp\/wp-json\/wp\/v2\/posts\/59","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kutila.fi\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kutila.fi\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kutila.fi\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kutila.fi\/wp\/wp-json\/wp\/v2\/comments?post=59"}],"version-history":[{"count":8,"href":"https:\/\/kutila.fi\/wp\/wp-json\/wp\/v2\/posts\/59\/revisions"}],"predecessor-version":[{"id":67,"href":"https:\/\/kutila.fi\/wp\/wp-json\/wp\/v2\/posts\/59\/revisions\/67"}],"wp:attachment":[{"href":"https:\/\/kutila.fi\/wp\/wp-json\/wp\/v2\/media?parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kutila.fi\/wp\/wp-json\/wp\/v2\/categories?post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kutila.fi\/wp\/wp-json\/wp\/v2\/tags?post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}