Search code examples
pdfghostscriptjbig2ccitt

How to convert a pdf with Ghostscript so the images will be encoded in CCITT


I'm trying to reduce the size of a pdf file by converting its images from color/gray to B/W and re-encode those images using the more efficient CCITT Group 4 or JBIG2 encoding.

Can it be done via Ghostscript? How? If not, is there another CLI tool that can help?


Solution

  • Yes Ghostscript can be used many ways with MonoChrome Group 4 compression. Halftone/Dithered will be needed for GreyTones.

    CCITT g4 is a highly efficient Monochrome FaX scanner / printer format, its GhostScript device output is available as:-

    -sDEVICE=faxg4 and also can be used inside a multi page tiff -sDEVICE=tiffg4 or also as individual pages via -sDEVICE=tiffsep1

    it can also be specified using -sCompression=g4

    see https://ghostscript.com/doc/current/Devices.htm#fax

    and https://ghostscript.com/doc/current/Devices.htm#TIFF

    Ghostscript JBIG2 support is uni-directional as they provide a DeCoder library for decoding JBIG2 streams in PDF files. Thus its primary focus is the set of JBIG2 features supported in PDF. So it is used in decoding for PDL outputs but not as a compression DEVICE.