Created
November 21, 2023 07:22
-
-
Save jtchen2k/085065a67349dd780de7259d92ec8151 to your computer and use it in GitHub Desktop.
pdfout.sh
This file contains hidden or 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
# https://ghostscript.com/docs/9.54.0/VectorDevices.htm# | |
# Presets (Not recommended as it sets too many properties) | |
# -dPDFSETTINGS=/screen (screen-view-only quality, 72 dpi images) | |
# -dPDFSETTINGS=/ebook (low quality, 150 dpi images) | |
# -dPDFSETTINGS=/printer (high quality, 300 dpi images) | |
# -dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs) | |
# -dPDFSETTINGS=/default (almost identical to /screen) | |
# Another reference: https://stackoverflow.com/a/72974400/10926869 (include a cmdline ) | |
# Great images but large size | |
# -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode \ | |
# Use QFactor to change JPEG quality https://stackoverflow.com/a/49334424/10926869 | |
# Somehow it is not working, gs seems not reading the QFactor. The only way to set seems to be using dPDFSETTINGS | |
# Prefer using this version to avoid strange issues that characters are missing in some files | |
# docker run --rm -v `pwd`:/app -w /app minidocks/ghostscript:9 \ | |
DPI=600 | |
gs -sDEVICE=pdfwrite -sOutputFile=output.pdf \ | |
-dCompatibilityLevel=1.7 -dFastWebView=true \ | |
-dEmbedAllFonts=true -dSubsetFonts=true -dCompressFonts=true \ | |
-dDetectDuplicateImages=true -dDoThumbnails=false -dAutoRotatePages=/None \ | |
-r$DPI -dColorImageResolution=$DPI -dGrayImageResolution=$DPI -dMonoImageResolution=$DPI \ | |
-dDownsampleColorImages=true -dColorImageDownsampleType=/Bicubic -dColorImageDownsampleThreshold=1.0 \ | |
-dDownsampleGrayImages=true -dGrayImageDownsampleType=/Bicubic -dGrayImageDownsampleThreshold=1.0 \ | |
-dDownsampleMonoImages=true -dMonoImageDownsampleType=/Subsample -dMonoImageDownsampleThreshold=1.0 \ | |
-dColorImageFilter=/DCTEncode -dGrayImageFilter=/DCTEncode -dMonoImageFilter=/CCITTFaxEncode \ | |
-dColorConversionStrategy=/LeaveColorUnchanged -dPassThroughJPEGImages=true \ | |
-dUseArtBox -dNEWPDF=true -dNOPAUSE -dBATCH -dSAFER \ | |
-dPDFSETTINGS=/printer \ | |
-c '<< /ColorACSImageDict << /VSamples [ 1 1 1 1 ] /HSamples [ 1 1 1 1 ] /QFactor 0.15 /Blend 1 /ColorTransform 1 >> >> setdistillerparams ' \ | |
-f input.pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment