Skip to content

crop --lossless of a non-JPEG source produces a mixed-codec pyramid (reduced levels always JPEG) #28

Description

@cornish

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions