mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-29 04:28:20 -06:00
encode_jpeg and encode_tiff composited the raster over white with as_chunks::<4>(), which drops a partial trailing pixel, and handed the result to encoders that trust its length. Run before this change: - JPEG: a partial pixel at the end was dropped and the rest written as a valid image; a buffer a pixel short, a pixel too many, empty, or with a size whose byte count overflows panicked (image's JpegEncoder checks the length with assert_eq!). - TIFF: a partial pixel or a pixel too many was written as a valid image; a buffer a pixel short panicked (tiff's write_data compares the buffer with the pixel count, not the sample count, then slices). The length check encode_png gained in #2425 is now check_raster, and all three encoders call it first. Rendered pages are always the right size, so what Export > Image writes is unchanged. export::raster_tests::rasters_of_the_wrong_length_are_rejected now runs its seven cases through PNG, JPEG and TIFF; it fails without the fix at "JPEG, opaque, a partial pixel after". rasters_of_no_pixels_are_an_error covers 0x0, 0x3 and 3x0, which are the right length and still errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BfMGHQNgdq5yf5tKZHGR3z