Public bug reported:

## Summary

On Ubuntu 24.04 (noble), choosing Black & White / Grayscale prints in
color on driverless color printers. libcupsfilters 2.0.0 renders every
page as sRGB for PWG raster and URF output, ignoring the PPD's
`ColorModel=Gray` and `print-color-mode=monochrome`. Printers that
receive an sRGB raster print it in color.

This is fixed upstream and confirmed by a Linux Mint 22 / noble user
with a similar Brother inkjet:

- https://github.com/OpenPrinting/libcupsfilters/issues/38 ("universal filter 
generates RGB image/urf for the monochrome printer")
- https://github.com/OpenPrinting/libcupsfilters/issues/125 (Brother 
MFC-J3540DW, noble packages, closed as a duplicate of #38). The maintainers 
asked for a distro backport of commits `c6175a2` and `78cc675`, which are in 
2.1.0. The reporter confirmed that patching fixed it.
- Also relevant: https://github.com/OpenPrinting/libcupsfilters/pull/127 ("Use 
ColorModel or output-mode if there's no print-color-mode")

Please backport these to noble's libcupsfilters (2.0.0-0ubuntu7.2).

## Interaction with cups (important for testing the backport)

On noble, jobs that request `ColorModel=Gray` also carry `print-color-
mode=color`, the queue default, derived from the PPD's
`DefaultColorModel: RGB`. With the fixed libcupsfilters, `print-color-
mode` takes priority over `ColorModel`, so a default-color queue would
still print in color from a Gray print dialog. Test with a queue whose
`print-color-mode-default` is `monochrome`.

cupsd is not the culprit: upstream b0f1a00 / c114e3c, which noble's
2.4.7 has, stop it from adding the default. The client adds it. libcups
turns `print-color-mode-default` into a destination option, and `lp`
(and apparently Chrome) merge it into the job without checking
`ColorModel`. This is still unfixed upstream:
https://github.com/OpenPrinting/cups/issues/1778. See also LP: #2142461.

Repro for that part, no paper needed:

```
lp -d QUEUE -o job-hold-until=indefinite -o ColorModel=Gray t.txt
# Get-Job-Attributes (ipptool) on the held job:
#   ColorModel = Gray
#   print-color-mode (keyword) = color
cancel QUEUE-<id>
# The same job sent with ipptool (ColorModel only) gets no print-color-mode.
```

## Versions

- Linux Mint 22.3 (noble base) with Ubuntu packages: libcupsfilters2t64 
2.0.0-0ubuntu7.2, cups-filters 2.0.0-0ubuntu4.1, cups 2.4.7-1.2ubuntu7.14, 
cups-browsed 2.0.0-0ubuntu10.3, ghostscript 10.02.1~dfsg1-0ubuntu7.9
- Printer: Brother MFC-J4335DW (color inkjet). Driverless only: 
`document-format-supported` = image/urf, image/pwg-raster, image/jpeg (no PDF). 
`pwg-raster-document-type-supported` = sgray_8, srgb_8. `urf-supported` 
includes W8 and SRGB24.

## Reproduce (no paper needed)

```
lpadmin -p QUEUE -o print-color-mode-default=monochrome -o ColorModel=Gray   # 
sidestep the cups-side issue
curl -s http://localhost:631/printers/QUEUE.ppd -o q.ppd
cupsfilter -p q.ppd -m image/urf -o ColorModel=Gray -o 
print-color-mode=monochrome color.pdf > out.urf 2> log.txt
grep 'Ghostscript command line' log.txt
#   ... -sDEVICE=cups -sMediaClass=PwgRaster ... -dcupsColorSpace=19 ... 
-sOutputICCProfile=srgb.icc
```

- The URF page header has 24 bpp, color space 1 (sRGB), and decoding the pixels 
shows the red test square still red.
- It's the same with `-m image/pwg-raster` (cupsColorSpace 19, 24 bpp).
- With a PPD whose only ColorModel choice is Gray (`<</cupsColorSpace 18 
...>>setpagedevice`), the output is byte-for-byte identical to RGB.
- A capture through the real cupsd shows the same thing: a temporary queue with 
the same PPD and `-v socket://127.0.0.1:9101`, with `nc -l 127.0.0.1 9101 > 
cap.urf`. Jobs that carry `print-color-mode=monochrome` still print in color on 
paper.

## Workaround (for anyone who finds this)

Convert to grayscale before the universal filter, on a dedicated queue:

1. Install `/usr/lib/cups/filter/bw-grayscale` (root, 755). It runs `gs 
-sDEVICE=pdfwrite -sColorConversionStrategy=Gray 
-dProcessColorModel=/DeviceGray` on PDF and PostScript input and passes other 
input through unchanged.
2. Add this line to the queue's PPD (`lpadmin -P`), and set 
`print-color-mode-default=monochrome`:
   ```
   *cupsPreFilter: "application/vnd.universal-input 0 bw-grayscale"
   ```

The pre-filter must be keyed on `application/vnd.universal-input`.
Keying it on `application/pdf` silently does nothing with cups-filters
2.x, because `application/pdf → application/vnd.universal-input` is a
null (`-`) conversion that cupsd drops before matching pre-filters.

Captured output was then 0 colored pixels, and Chrome jobs print black
and white on paper even with Color selected.

##AI Disclosure

Claude wrote this for me after we spent an hour or so getting black &
white printing working for me.  One of several issues that made it hard
to puzzle out.

** Affects: libcupsfilters (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2171466

Title:
  Noble: driverless (IPP Everywhere / URF / PWG) printing always in
  color: please backport libcupsfilters color-space fixes (upstream #38
  / #125)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/libcupsfilters/+bug/2171466/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to