mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-24 18:18:12 -06:00
Bilevel scans, CCITT fax images and 2- or 4-bit gray TIFFs were rejected with "sample buffer too short". The `tiff` crate returns such samples packed, most significant bits first, eight, four or two to a byte with each row padded to a whole byte; the converter expects one byte per sample. They are now spread out one per byte and scaled to 0–255 (255, 85 and 17 times the sample: exact) before conversion. 3-, 5-, 6- and 7-bit samples, and planar images with more than one sample narrower than a byte, are refused with an "unsupported" error. The new test builds 1-bit (both photometric conventions, a width that leaves row padding, set padding bits), 2-bit and 4-bit strips in code, plus a truncated strip that must fail cleanly; it fails without the fix with the old error. A 600×400 bilevel image, uncompressed and CCITT G4, now decodes to the same pixels PIL reads from it. The module documentation no longer claims palette support: the `tiff` crate refuses RGBPalette images on every read path, so the palette branch here has never been reached. The parity row lists palette TIFF as missing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>