Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it easier to write a non-tiff vips source #830

Merged
merged 1 commit into from
Apr 19, 2022
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Unreleased

### Features
- Vips tile source and tiled file writer ([816](../../pull/816))
- Vips tile source and tiled file writer ([816](../../pull/816), [827](../../pull/827), [830](../../pull/830))

### Improvements
- Handle file URLs with GDAL ([820](../../pull/820))
Expand Down
6 changes: 4 additions & 2 deletions sources/vips/large_image_source_vips/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import threading
import uuid
from pathlib import Path

import cachetools
import numpy
Expand Down Expand Up @@ -445,8 +446,9 @@ def write(self, path, lossy=True, alpha=True, overwriteAllowed=True, vips_kwargs
x = min(x, img.width)
y = min(y, img.height)
img = img.crop(x, y, w, h)
if vips_kwargs is not None:
img.write_to_file(path, **vips_kwargs)
pathIsTiff = Path(path).suffix.lower() in {'tif', 'tiff'}
if vips_kwargs is not None or not pathIsTiff:
img.write_to_file(path, **(vips_kwargs or {}))
elif not lossy:
img.write_to_file(
path, tile_width=self.tileWidth, tile_height=self.tileHeight,
Expand Down