Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Image Structure
COMPRESSION: LZW
INTERLEAVE: BAND
OVERVIEW_RESAMPLING: BILINEAR
PREDICTOR: 2

Band 1
ColorInterp: gray
Expand Down
Binary file modified rasterio_generated/fixtures/uint16_1band_scale_offset.tif
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Image Structure
COMPRESSION: DEFLATE
INTERLEAVE: BAND
OVERVIEW_RESAMPLING: BILINEAR
PREDICTOR: 2

Band 1
ColorInterp: gray
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Image Structure
COMPRESSION: DEFLATE
INTERLEAVE: BAND
OVERVIEW_RESAMPLING: BILINEAR
PREDICTOR: 2

Band 1
ColorInterp: gray
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Image Structure
COMPRESSION: LZW
INTERLEAVE: BAND
OVERVIEW_RESAMPLING: BILINEAR
PREDICTOR: 2

Band 1
ColorInterp: gray
Expand Down
6 changes: 3 additions & 3 deletions rasterio_generated/write_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ def write_cog(
"transform": transform,
}

if predictor is not None:
src_profile["predictor"] = predictor

if nodata is not None:
src_profile["nodata"] = nodata

Expand Down Expand Up @@ -169,5 +166,8 @@ def write_cog(
if compress_level is not None:
cog_profile["level"] = compress_level

if predictor is not None:
cog_profile["predictor"] = predictor

# Copy to output path
copy(mem, path, copy_src_overviews=True, **cog_profile)
26 changes: 26 additions & 0 deletions tests/test_predictor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Check that fixtures generated with a predictor carry it on every IFD.

write_cog once set the predictor on its in-memory dataset only, so the COGs it
wrote silently used no predictor.
"""

from pathlib import Path

import pytest
import tifffile

FIXTURES_DIR = Path(__file__).parent.parent / "rasterio_generated" / "fixtures"


@pytest.mark.parametrize(
"name",
[
"uint16_1band_lzw_block128_predictor2",
"uint16_1band_scale_offset",
"uint8_1band_deflate_block128_unaligned_predictor2",
"uint8_1band_lzw_block64_predictor2",
],
)
def test_predictor_2(name: str):
with tifffile.TiffFile(FIXTURES_DIR / f"{name}.tif") as tif:
assert [int(page.predictor) for page in tif.pages] == [2] * len(tif.pages)
Loading