I have a colour PDF file, and I'm going to print it out and then photocopy it in black and white. I'd like to know what it's like in B&W before photocopying it. Is it possible to 'greyscale' a PDF on the command line using free software? I'm using Ubuntu 9.10.
4 Answers
Better:
gs \
-sOutputFile=output.pdf \
-sDEVICE=pdfwrite \
-sColorConversionStrategy=Gray \
-dProcessColorModel=/DeviceGray \
-dCompatibilityLevel=1.4 \
-dNOPAUSE \
-dBATCH \
input.pdf
- 6,473
-
38That significantly reduces quality. @goyinux' solution is better. – Johannes Weiss Feb 12 '13 at 16:41
-
8Convert will actually rasterize the contents of the pdf. So unless the pdf already encapsulates only raster images (e.g. a scanned document), this approach is a big no-no. – m000 Sep 19 '14 at 12:24
-
4
-
2
-
1
-density 400 -quality 100creates HUGE files. +1 for @goyinux's solution. – Stanimir Stoyanov Jun 27 '18 at 10:45 -
The big files print great (only using black toner) while the original and gs-converted file use all toners and create a vague mess on my printer. – rew Jan 10 '19 at 11:59
-
What's the reason for
convertto reduce the quality of rasterized images? I tried using the optionsconvert -density 300 -quality 100, in order to prevent this behaviour ofconvert. But the quality of the output image is still much worse than the quality of the input image... so are there options forconvert, that prevent the encapsulated images from quality loss, when convertingpdf'-files encapsulating rasterized images? – ArchLinuxTux Apr 30 '19 at 16:45 -
Another problem with
convertis that OCRed pdf files lose the text layer. That is, one loses the OCR. While the method withgskeeps OCR. – loved.by.Jesus Sep 09 '20 at 13:07 -
convert -density 200 -colorspace GRAYworked like a charm for me – Jean Carlo Machado Mar 24 '21 at 09:31 -
With proper
-densityit gives nice grayscale. In case you need black/white with clean background it is more suitable-density 300 -threshold 75%. It may be useful when you keep original scans in color and want to reprint it. – x'ES Nov 07 '23 at 16:00
Here’s a little script which in addition to the grayscale conversion can concatenate multiple input files. To use the script, put the following lines in a file, e.g. "convert2gray.sh"
#!/bin/bash
gs -sOutputFile=converted.pdf -sDEVICE=pdfwrite -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray -dCompatibiltyLevel=1.4 -dNOPAUSE -dBATCH $@
and make it executable
chmod +x convert2gray.sh
Then
./convert2gray.sh input1.pdf input2.pdf … lastinput.pdf
will produce a single PDF "converted.pdf", which contains all pages from the input files converted to grayscale.
I had to print out mutliple files all in grayscale and found this the easiest way, since you can print out everything after inpection with one command.
- 161
In my case I am keeping signed document scans in color, but need reprint it without gray noice. For this case works well
convert -density 300 -threshold 75% input.pdf output.pdf
(based on the answer)
Range between 50%-75% works fine in circumstances when you have color scan PDF (text as image) with original resolution 300dpi.
In case of text saved as PDF (not image) you will get huge increasing of output file size.
- 101
- 1
-dAutoRotatePages=/None– tdc Aug 07 '12 at 18:15\\and put everything on the same line. – ixe013 Aug 19 '14 at 04:23GPL Ghostscript 9.10: Unable to convert color space to Gray, reverting strategy to LeaveColorUnchanged.– jjmerelo Dec 15 '15 at 17:56-dPDFSETTINGS=/ebook. Instead of/ebookyou can also use/screenfor a more radical compression (i.e. lower quality). Enjoy it! – loved.by.Jesus Sep 09 '20 at 13:21-dPDFSETTINGS=/screenis really loq quality, which the original file may not have been. – ivo Welch May 02 '23 at 21:33