Skip to content

Instantly share code, notes, and snippets.

@bokunodev
Last active November 19, 2020 01:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bokunodev/62a410c35c27204b7d6ca4a2b0325fd3 to your computer and use it in GitHub Desktop.
Save bokunodev/62a410c35c27204b7d6ca4a2b0325fd3 to your computer and use it in GitHub Desktop.
convert pdf file from RGB to CYMK using ghost script
#!/usr/bin/bash
help(){
echo "Usage: $0 <input.pdf> <output.pdf> [safe]"
echo "optional \`safe\` option, preform less processing, possibly better quality with a much larger file size."
exit 127
}
if [[ $1 == "" ]] ; then
echo "Missing parameter input pdf file"
help
elif [[ $2 == "" ]] ; then
echo "Missing parameter output pdf file"
help
fi
case $3 in
"safe")
gs -dSAFER -dBATCH -dNOPAUSE -dNOCACHE -sDEVICE=pdfwrite -dAutoRotatePages=/None -sColorConversionStrategy=CMYK -dProcessColorModel=/DeviceCMYK -dAutoFilterColorImages=false -dAutoFilterGrayImages=false -dColorImageFilter=/FlateEncode -dGrayImageFilter=/FlateEncode -dDownsampleMonoImages=false -dDownsampleGrayImages=false -sOutputFile="$2" "$1"
;;
"")
gs -dSAFER -dBATCH -dNOPAUSE -dNOCACHE -sDEVICE=pdfwrite -dAutoRotatePages=/None -sColorConversionStrategy=CMYK -dProcessColorModel=/DeviceCMYK -sOutputFile="$2" "$1"
;;
*)
echo "Unknown parameter \`$3\`"
help
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment