3

I want to convert a pdf to grayscale using mutool. there is an option for grayscale in convert but i don't know how to run it there is no documentation, here is what i am trying to run

$ mutool convert colorspace=gray input.pdf output.pdf

but it doesn't work, it just shows the documentation as below

$ mutool convert
mutool convert version 1.10a
Usage: mutool convert [options] file [pages]
  -p -  password

  -A -  number of bits of antialiasing (0 to 8)
  -W -  page width for EPUB layout
  -H -  page height for EPUB layout
  -S -  font size for EPUB layout
  -U -  file name of user stylesheet for EPUB layout

  -o -  output file name (%d for page number)
  -F -  output format (default inferred from output file name)
    cbz, pdf, png
  -O -  comma separated list of options for output format

  pages comma separated list of page ranges (N=last page)

Common raster format output options:
  rotate=N: rotate rendered pages N degrees counterclockwise
  resolution=N: set both X and Y resolution of rendered pages in pixels per inch
  x-resolution=N: X resolution of rendered pages in pixels per inch
  y-resolution=N: Y resolution of rendered pages in pixels per inch
  width=N: render pages to fit N pixels wide (ignore resolution option)
  height=N: render pages to fit N pixels tall (ignore resolution option)
  colorspace=(gray|rgb|cmyk): render using specified colorspace
  alpha: render pages with alpha channel and transparent background

Structured text output options:
  preserve-ligatures: do not expand all ligatures into constituent characters
  preserve-whitespace: do not convert all whitespace characters into spaces

PDF output options:
  decompress: decompress all streams (except compress-fonts/images)
  compress: compress all streams
  compress-fonts: compress embedded fonts
  compress-images: compress images
  ascii: ASCII hex encode binary streams
  pretty: pretty-print objects with indentation
  linearize: optimize for web browsers
  sanitize: clean up graphics commands in content streams
  garbage: garbage collect unused objects
  or garbage=compact: ... and compact cross reference table
  or garbage=deduplicate: ... and remove duplicate objects

1 Answer 1

3

After some playing around I found out that I need -O attribute before colorspace=gray and also -o for output file like this

$ mutool convert -O colorspace=gray -o output.pdf input.pdf

would be nice if the developers would add (required) to the items that are necessary in the documentation, like this maybe

-o -  output file name (required)
1
  • The command completes without error, but the document still has colors.
    – sekrett
    Dec 15, 2021 at 14:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .