2

I have my default printer set: lpoptions -d HP_ENVY_5530_series. I can print some text:

echo HELLO > h.txt
lp h.txt

CUPS understands many different types of files directly, including text, PostScript, PDF, and image files.

I can print a Portable Network Graphics: lp Gnome2.26-printing-dialogue.png.

A Scalable Vector Graphics: lp Cups_simple.svg - prints as its internal text contents, which isn't much use.

A scanned JPEG: lp 022.jpg - gets stopped "Unable to open image file for printing!". If I convert it to a PNG with ImageMagick - convert 022.jpg 022.png, I can then print it lp 022.png.

I would like an explanation for these limitations of the CUPS lp command.

  • You have a belief that lpr is expected to transform files into the representation you want. SVG is text. My question is why the PNG file works at all. – msw Dec 26 '15 at 22:43
  • 1
    @msw That's not a duplicate, it provides workarounds but not an explanation of how CUPS recognizes input formats. – Gilles Dec 26 '15 at 23:04
  • On what distribution is this? What CUPS-related packages are installed? CUPS can only print the input formats that it recognizes, but I'm surprised that it would recognize PNG and not JPEG. – Gilles Dec 26 '15 at 23:04
  • @Gilles, hplip-3.15.11 is the only CUPS-related package I can think of in my Arch Linux installation. – JosephHarriott Dec 26 '15 at 23:22
1

CUPS has a filter mechanism to detect the format of its input and convert it to a built-in format (PostScript or to a raster image).

CUPS has a database of file names and magic numbers (distinct from the one used by the file command, but serving a similar purpose and operating on similar principles). It uses this database to construct a transformation chain between the input and a built-in format.

The database is located in /usr/share/cups/mime/ on Arch Linux and Ubuntu; other distributions may use a different path.

If CUPS doesn't recognize the input format, depending on how the filters are set up, it may either assume text or refuse printing. Look for a line containing just application/octet-stream (with nothing else afterwards) in your filters; if it's present, then unrecognized input is passed to the printer, otherwise it'll be rejected as unprintable.

Note that input that looks like text, for example SVG, will be printed as text in any sane configuration. If your installation has nothing that defines the SVG format, then SVG will be recognized under some generic text rule and printed as is.

There's some good documentation about writing filters on the SuSE wiki.

You should install at least the cups-filters package (formerly by Apple and included in CUPS itself, now maintained by OpenPrinting). There's a package in Arch. This includes a filter for JPEG, but not for SVG.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.