diff --git a/negpy/services/rendering/image_processor.py b/negpy/services/rendering/image_processor.py index a6171200..e9969223 100644 --- a/negpy/services/rendering/image_processor.py +++ b/negpy/services/rendering/image_processor.py @@ -361,7 +361,8 @@ def _encode_export( img_out, photometric="rgb" if img_out.ndim == 3 else "minisblack", iccprofile=icc_bytes, - compression="lzw", + compression="zlib", + predictor=True, ) return output_buf.getvalue(), "tiff" elif fmt == ExportFormat.DNG: diff --git a/negpy/services/scanning/writer.py b/negpy/services/scanning/writer.py index 20830613..ba2c0d02 100644 --- a/negpy/services/scanning/writer.py +++ b/negpy/services/scanning/writer.py @@ -37,7 +37,7 @@ def write_tiff_16bit(result: ScanResult, path: str) -> str: fd, tmp_path = tempfile.mkstemp(suffix=".tif", dir=os.path.dirname(path) or ".") os.close(fd) try: - tifffile.imwrite(tmp_path, rgb, photometric="rgb", compression="lzw") + tifffile.imwrite(tmp_path, rgb, photometric="rgb", compression="zlib", predictor=True) os.replace(tmp_path, path) except Exception: if os.path.exists(tmp_path): @@ -51,7 +51,7 @@ def write_tiff_16bit(result: ScanResult, path: str) -> str: fd_ir, tmp_ir = tempfile.mkstemp(suffix=".tif", dir=os.path.dirname(ir_path) or ".") os.close(fd_ir) try: - tifffile.imwrite(tmp_ir, ir_data, photometric="minisblack", compression="lzw") + tifffile.imwrite(tmp_ir, ir_data, photometric="minisblack", compression="zlib", predictor=True) os.replace(tmp_ir, ir_path) except Exception: if os.path.exists(tmp_ir): diff --git a/tests/metadata/test_writer.py b/tests/metadata/test_writer.py index 13cf2691..aae056ea 100644 --- a/tests/metadata/test_writer.py +++ b/tests/metadata/test_writer.py @@ -14,7 +14,7 @@ def _make_tiff_bytes() -> bytes: """16-bit RGB TIFF in the shape produced by the real export pipeline.""" arr = np.random.randint(0, 65535, (16, 16, 3), dtype=np.uint16) buf = io.BytesIO() - tifffile.imwrite(buf, arr, photometric="rgb", compression="lzw") + tifffile.imwrite(buf, arr, photometric="rgb", compression="zlib", predictor=True) return buf.getvalue() diff --git a/tests/test_export_service.py b/tests/test_export_service.py index 8574777a..8ed37074 100644 --- a/tests/test_export_service.py +++ b/tests/test_export_service.py @@ -65,7 +65,8 @@ def test_image_service_tiff_export_format() -> None: img_16, photometric="rgb", iccprofile=b"fake_icc_bytes", - compression="lzw", + compression="zlib", + predictor=True, ) res = out_buf.getvalue() assert len(res) > 0