Summary
crop --lossless of a non-JPEG source produces an internally mixed-codec
pyramid: L0 is copied verbatim (source codec) but the re-encoded reduced levels
are always JPEG. On a JPEG 2000 SVS:
$ wsitools crop --lossless --x 4000 --y 4000 --w 8192 --h 8192 -o out.svs JP2K-33003-1.svs
$ wsitools info out.svs
L0 ... jpeg2000 <- verbatim copy (source codec)
L1 ... jpeg <- re-encoded reduced level
L2 ... jpeg
...
So a JPEG 2000 slide cropped losslessly becomes JPEG below L0 — a mixed-codec
pyramid the user did not ask for.
Cause
Same root cause as the lossless-crop chroma-subsampling bug (already fixed):
buildPyramidFromRaster / buildPyramidFromRasterCOGWSI (via encodeAndWriteLevel)
hardcode the JPEG encoder (jpegcodec.Factory{}), so the reduced levels are JPEG
regardless of the source / L0 codec.
Fix direction
Re-encode the reduced levels in the source codec (mirror the chroma fix that
threaded sourceJPEGSubsampling — here thread the source codec / a codec factory
into buildPyramidFromRaster*), so a JP2K source yields a uniform JP2K pyramid.
For codecs with no lossless-crop encoder, either use them or error clearly rather
than silently emitting JPEG.
Found by
The automated CLI matrix audit (scripts/qa/audit.sh, codec-uniform invariant).
Summary
crop --losslessof a non-JPEG source produces an internally mixed-codecpyramid: L0 is copied verbatim (source codec) but the re-encoded reduced levels
are always JPEG. On a JPEG 2000 SVS:
So a JPEG 2000 slide cropped losslessly becomes JPEG below L0 — a mixed-codec
pyramid the user did not ask for.
Cause
Same root cause as the lossless-crop chroma-subsampling bug (already fixed):
buildPyramidFromRaster/buildPyramidFromRasterCOGWSI(viaencodeAndWriteLevel)hardcode the JPEG encoder (
jpegcodec.Factory{}), so the reduced levels are JPEGregardless of the source / L0 codec.
Fix direction
Re-encode the reduced levels in the source codec (mirror the chroma fix that
threaded
sourceJPEGSubsampling— here thread the source codec / a codec factoryinto
buildPyramidFromRaster*), so a JP2K source yields a uniform JP2K pyramid.For codecs with no lossless-crop encoder, either use them or error clearly rather
than silently emitting JPEG.
Found by
The automated CLI matrix audit (
scripts/qa/audit.sh,codec-uniforminvariant).