Created
November 4, 2014 17:07
-
-
Save rsnemmen/76d1ce067aaa2e306ec4 to your computer and use it in GitHub Desktop.
Perl script to convert a color PDF to grayscale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
# | |
# Source: http://handyfloss.net/2008.09/making-a-pdf-grayscale-with-ghostscript/ | |
# handyfloss blog | |
# | |
# Usage: pdf2gray.pl input_color.pdf | |
use strict; | |
my $infile = $ARGV[0]; | |
my $outfile = $infile; | |
$outfile =~ s/\.pdf$//; | |
$outfile = $outfile."_gray.pdf"; | |
system "gs -sOutputFile=$outfile -sDEVICE=pdfwrite -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH $infile" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment