# Create PDF with images in black and white

I have a LaTeX document with several black and white, gray value, and color images. When creating a PDF with pdfLaTeX I get a PDF where I am not sure if the embedded black and white images are actually set as black and white (important for the printing costs).

Is there a way to test which images are set as black and white, gray value, and color; and if necessary force pdfLaTeX to set them as black and white?

-
`pdftex` doesn't change the color settings of included images AFAIK. You would need to do this using an image manipulation program. Have a look at Detecting all pages which contain color and the linked SO post there. –  Martin Scharrer Jun 14 '12 at 8:26
Setting color LaTeX generated PDF to print in black & white the answer here might be helpfull –  Rick de Groot Jun 15 '12 at 9:04

Ghostscript can convert color documents into grayscale. Example commandline:

``````gs \
-o grayscale.pdf \
-sDEVICE=pdfwrite \
-sColorConversionStrategy=Gray \
-sProcessColorModel=/DeviceGray \
/path/to/your.pdf
``````

The most recent version of Ghostscript can also check for the CMYK ink coverage of PDF documents (not image by image, but page by page), using a new "device" called `inkcov`. Check for the ink coverage of an example PDF:

``````gs -o - -sDEVICE=inkcov /path/to/your.pdf
``````

Example output:

``````Page 1
0.00000  0.00000  0.00000  0.02230 CMYK OK
Page 2
0.02360  0.02360  0.02360  0.02360 CMYK OK
Page 3
0.02525  0.02525  0.02525  0.00000 CMYK OK
Page 4
0.00000  0.00000  0.00000  0.01982 CMYK OK
``````

Here 1.00000 would mean 100%, 0.02525 means 2.525% and 0.00000 means 0% ink coverage. You can see here that pages 1+4 are using no color, while pages 2+3 do. This case is particularly 'nasty' for people who want to save on color ink: because all the C, M, Y (and K) values are exactly the same for each of the pages 2+3, they possibly could appear to the human eye not as color pages, but as grayscale (or "rich" grayscale in the case of page 3) anyway. (That is, if each single pixel is mixed with these color values -- of course, if the page is made by four different squares of the same size using "pure" colors each, then you'd get the same ink coverage result).

Now convert the original PDF to a grayscale one, using the command I initially gave. Then check for the ink coverage distribution again (note how the addition of `-q` to the parameters slightly changes the output format):

``````gs -q  -o - -sDEVICE=inkcov grayscale.pdf
0.00000  0.00000  0.00000  0.02230 CMYK OK
0.00000  0.00000  0.00000  0.02360 CMYK OK
0.00000  0.00000  0.00000  0.02525 CMYK OK
0.00000  0.00000  0.00000  0.01982 CMYK OK
``````
-
Just a remark: Ghostscript sometimes automatically rotates pages when there's "a lot" of landscape text. This is very inconvenient especially when you convert pictures (graphs) to greyscale to be used by `\includegraphics`. To suppress this, add the option `-dAutoRotatePages=/None \ `. –  yo' Oct 6 '12 at 8:07
@Kurt, this is really minor, but am I reading the output of `inkcov` wrong, or is page 1 in your example also black and white? I can't understand what the difference between pages 1 and 4 might be. –  jja Mar 4 '13 at 12:30
@jja: You are right. You spotted an error I made when writing down my notes about the example I used. I'll edit the answer accordingly. Thanks for telling. –  Kurt Pfeifle Mar 12 '13 at 9:17
I tried this and got an error: "Unrecoverable error: rangecheck in .putdeviceprops" –  Erel Segal-Halevi Aug 11 at 5:33
@ErelSegal-Halevi: What is the output of `gs -version` ? –  Kurt Pfeifle Aug 11 at 6:05