Skip to content

Commit

Permalink
Merge pull request #830 from girder/better-vips-write-defaults
Browse files Browse the repository at this point in the history
Make it easier to write a non-tiff vips source
  • Loading branch information
manthey authored Apr 19, 2022
2 parents 51c647b + 2747530 commit cad9126
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
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

0 comments on commit cad9126

Please sign in to comment.