kno10 / python-scan-eSCL

Scan using a network scanner with eSCL protocol (e.g. Canon PIXMA)
GNU Affero General Public License v3.0
16 stars 4 forks source link

Tiff Images #3

Open trumad opened 5 years ago

trumad commented 5 years ago

Hi! Thanks for this - it's very handy and works perfectly for the TS5051.

Is it possible to have the output file be a tiff file?

kno10 commented 5 years ago

The printer I have only offered JPEG if I recall correctly. Check the XML file with the options.

kno10 commented 5 years ago

In the XML of another (HP) user, I saw <pwg:DocumentFormat>application/octet-stream</pwg:DocumentFormat>. That may be a raw pixel format that - if you can identify the data layout - be converted to tiff. You can check what your printer supports easily, the XML is not hard to read.

trumad commented 5 years ago

Super, thank you for taking the time to look into this. I haven't yet gotten back to this project, but I will take a closer look at the XML the printer outputs and update the thread with my findings. You can close this out if you like. Thanks!

debiantriage commented 5 years ago

In the XML of another (HP) user, I saw <pwg:DocumentFormat>application/octet-stream</pwg:DocumentFormat>. That may be a raw pixel format that - if you can identify the data layout - be converted to tiff. You can check what your printer supports easily, the XML is not hard to read.

Personally, I wouldn't fancy taking on that task. It would be easier to use ImageMagick's convert utility to get a tiff from a jpeg, either after scanning or by modifying Scan.py. Besides, the existence of application/octet-stream and its purpose as a DocumentFormat would need exploring.

The 'application/octet-stream' document format is used to tell the printer it should automatically detect the format. Detection accuracy varies widely between printers, so you should specify the actual format whenever possible.

https://ftp.pwg.org/pub/pwg/ipp/wd/wd-ippguide-20180918.pdf

kno10 commented 5 years ago

Well, JPEG is a lossy compression, and IIRC it only allows 24 bit color depth (or 8 bit grayscale). You can't undo the lossy compression by converting to tiff later... That is why 'raw' formats are popular with digital cameras; and I would assume that at least some scanners will provide a similar 'raw' format, probably with a raw bit depth, too. For some scanners, the x and y resolutions also vary, and jpeg may not be able to fully represent this (without distortion in all standard viewers). So I wouldn't be surprised if you just cannot make all the advertised functionality with jpeg alone. Raw formats may not have a mime type assigned, and then application/octet-stream is probably an okay choice to allow the official driver to select the raw format. So my guess is that this is the uncompressed raw format.