如何通过 mutool (mupdf-tools) 将 pdf 转换为灰度

如何通过 mutool (mupdf-tools) 将 pdf 转换为灰度

我想使用将 PDF 转换为灰度mutool。有一个灰度选项,convert但我不知道如何运行它,没有文档,这是我尝试运行的

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

但它不起作用,它只显示如下文档

$ 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

经过一番尝试,我发现我需要-O属性colorspace=gray,并且还-o需要像这样的输出文件

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

如果开发人员能够将(必需的)添加到文档中所需的项目中,那就太好了,就像这样

-o -  output file name (required)

相关内容