fix: black and white is shown as it prints, and right-click prints the picture
Printing through Elmer found two things. Black and white came out grey while the preview stayed in colour: 0.2.6.2 only told the driver. And right-clicking a picture in a lesson and choosing Print printed the whole page around it, where some pictures cannot be opened on their own at all. Black and white is now made before the preview. Ghostscript makes a grey copy, the preview shows it, and CUPS is given that same file, still with ColorModel=Grayscale so Elmer's PCL 6 driver prints with pxlmono. Measured first: Ghostscript's own grey of the colour original and of the copy give the same greys (Elmer's driver is Ghostscript); poppler's do not. It takes up to 4.4 s for a lesson page of pictures, so it runs in the background with a minute to finish, is made once and kept, and a failure is said so and never printed in colour instead. Ghostscript is now a named dependency; cups-filters already brought it. Right-click asks the engine's hit test: on a picture or a canvas it offers Print image and Print page, elsewhere only Print page. The picture comes from the engine's own copy image — the only one of five ways measured that worked for a signed-in picture, a hotlink-protected one, a one-time address, blob:, data:, another site's, a canvas and WebP — and it fetches nothing, so the teacher's sign-in is not needed again. It goes through the clipboard, which is kept and put back; measured under KWin with another program owning it. A picture that never arrives is said so; the page is not printed in its place. It then gets the 0.2.6.2 picture layout. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
550c0bf126
commit
594fbd810e
@@ -197,6 +197,42 @@ def parse_pages(text, count):
|
||||
return ",".join(parts)
|
||||
|
||||
|
||||
def grayscale_command(source, target):
|
||||
"""The command that writes SOURCE, in black and white, to TARGET.
|
||||
|
||||
Black and white is made here, before the preview, so the preview shows
|
||||
it and CUPS is given the same file — 0.2.6.2 only told the driver, and
|
||||
the preview stayed in colour while the paper came out grey. Measured in
|
||||
the lab (Ghostscript 10.05.1) on a lesson page, a picture page, a
|
||||
worksheet and a fillable form:
|
||||
|
||||
* the result is grey and nothing else, with the same pages, page
|
||||
sizes and words, and the text still text;
|
||||
* Ghostscript's own grey rendering of the colour original and of
|
||||
this file give the same greys — within 1 level in 255 on every
|
||||
filled area and picture; small text can land a fraction of a
|
||||
pixel over. Elmer's driver is Ghostscript, so this is what Elmer
|
||||
would have made of the colour file anyway — poppler's grey is
|
||||
not, and differs on 7% of a coloured page;
|
||||
* 0.05 s for a worksheet, 1.3 s for a full-page photograph, 2 s for
|
||||
42 pages, and 4.4 s for one lesson page with eleven full-size
|
||||
pictures, which is why the preview does it in the background.
|
||||
|
||||
Pages are never turned (pdfwrite otherwise rotates a page by its text)
|
||||
and annotations — a form field a teacher filled in, a mark on a
|
||||
worksheet — are drawn into the page as they print, so nothing is left
|
||||
for a later filter to draw again in colour.
|
||||
"""
|
||||
return [
|
||||
"gs", "-q", "-dSAFER", "-dBATCH", "-dNOPAUSE",
|
||||
"-sDEVICE=pdfwrite",
|
||||
"-sColorConversionStrategy=Gray", "-dProcessColorModel=/DeviceGray",
|
||||
"-dAutoRotatePages=/None",
|
||||
"-dPreserveAnnots=false", "-dPrinted",
|
||||
f"-sOutputFile={target}", "--", str(source),
|
||||
]
|
||||
|
||||
|
||||
def submit(pdf, printer, copies=1, pages=None, gray=None, title="Wonder Ink"):
|
||||
"""Hand a PDF to CUPS. (True, job id) or (False, what went wrong).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user