Repository navigation
fix(geotiff): byte-swap LERC tiles from big endian files - #705
Merged
Merged
Conversation
libtiff swaps samples into the file's byte order before passing them to any codec, LERC included, so the LERC data in a big endian file holds byte-swapped values. decode() only swapped codecs that return raw bytes, so LERC tiles from MM files came out byte-swapped. Swap typed pixels too when the file is big endian and samples are wider than 8 bits. Closes #704 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bump geotiff-test-data to pick up its big endian LERC fixtures (developmentseed/geotiff-test-data#81) and add both to the rasterio integration test. On main both fail tile pixel data matches. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This PR was written by Claude (Claude Code), not by @kylebarron.
Closes #704.
LERC tiles from big endian (
MM) files decoded byte-swapped. libtiff swaps samples into the file's byte order before passing them to any codec, LERC included, so the LERC data in a big endian file holds byte-swapped values. #687 only swapped the output of codecs that return raw bytes.Changes
decode()now also byte-swaps the typed pixels a codec returns when the file is big endian and samples are wider than 8 bits. In practice that means LERC, LERC_DEFLATE and LERC_ZSTD. JPEG and WebP output is 8-bit, so it's untouched.lercpackage copies decoded pixels out of WASM memory into a new buffer, so nothing else references it.swapBytesInPlacenow takes aUint8Array, because LERC bands aresubarrayviews into one shared buffer.Tests
decode.test.ts: decoding the existingfloat32_1band_lerc_block32tile as big endian must give exactly the little endian result with each sample's bytes reversed. It fails onmain.fixtures/geotiff-test-datato pick up its new big endian LERC fixtures (feat: Add big endian LERC fixtures geotiff-test-data#81) and adds both tointegration-rasterio.test.ts:uint16_1band_lerc_block64_big_endianandfloat32_1band_lerc_block64_big_endian. Both failtile pixel data matchesonmainand pass here. The bump also brings in geotiff-test-data ci(publish): Try to set registry-url in setup-node #78–feat: Only load COGLayer at first in the example app #80, which no test here uses.geotiff(166/166) with the rasterio integration suite, andpnpm typecheckandbiome checkare clean.🤖 Written by Claude Code