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
3 changes: 2 additions & 1 deletion negpy/services/rendering/image_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions negpy/services/scanning/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/metadata/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
3 changes: 2 additions & 1 deletion tests/test_export_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down