OpenPrinting / OpenPrinting/libcupsfilters

rasterize pdf that embeds non-regular dpi image using `cupsfilter` introduces nearest-neighbor like aliasing artifacts.

Open
#111 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
17
Forks
71
Avg merge
2d 17h
Merged PRs (30d)
13

Description

I was investigating a problem that the Canon Selphy CP1500 prints images 107% larger.
The printer uses the 'Canon SELPHY CP1500, driverless, cups-filter, 2.0.1' driver.

So I started to print an image of the 10x10mm and 1x1mm grid pattern in various software and various options.

Here's the grid image:
10x10mm and 1x1mm grid pattern images
254 dpi, 100mmx148mm(Hagaki size) png image. thick lines are 4px thick, 10mm spacing, thin lines are 2px thick, 1mm spacing.

and the printed results have nearest-neighbor-like aliasing artifacts.
the printed result with aliasing artifact

also found that it only happens with GIMP and non-300 dpi images (shotwell and darktable have no problem with non-300 dpi images).
300dpi images on GIMP and non-300 dpi images on shotwell and darktable

GIMP generates a PDF file /tmp/gtkprint* and streams the file to CUPS driver. I could intercept the generated pdf file: grid.pdf
The file has perfectly fine image, but the printed result had aliasing artifacts. This is where I started to suspect the rasterization filter in the CUPS driver.

I noticed this code here
https://github.com/OpenPrinting/libcupsfilters/blob/a02c49054ff828772b9edea083a3fe58e90e9b15/cupsfilters/imagetoraster.c#L1544-L1547

so I've modified the image to include colors to make the embedded image to have 8-bit color. here's the generated pdf file: color.pdf
But the result wasn't any better.

I found that I can manually invoke cupsfilter with a ppd file. Here's the ppd that I somehow salvaged from /tmp/ cp1500.txt (changed the extension to upload to GitHub)

cupsfilter -p cp1500.ppd -m image/urf -i application/pdf ./grid.pdf > grid.urf
urftobmp grid.urf

You can get urftobmp here: https://github.com/mbevand/urf2image
I got this error when I tried to convert it to jpeg.

cupsfilter: No filter to convert from application/pdf to image/jpeg.

Here's the urf result that has been converted to bmp.
urf_to_bmp_results.zip

You can see that both color.bmp and grid.bmp look like they were resized using the nearest-neighbor algorithm.

Here's the GIMP issue for reference: https://gitlab.gnome.org/GNOME/gimp/-/issues/15558

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the imagetoraster.c code linked in the report and reproduce the conversion using cupsfilter with cp1500.ppd, grid.pdf, and color.pdf. Inspect the generated URF with urftobmp and compare it with the attached BMP results; done means identifying and correcting the rasterization path that produces nearest-neighbor-like aliasing for non-300 DPI embedded images.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.