Skip to content

deepzoom: resize tiles to exact target dimensions - #389

Open
chenyangsu wants to merge 1 commit into
openslide:mainfrom
chenyangsu:fix/deepzoom-tile-size
Open

chenyangsu wants to merge 1 commit into
openslide:mainfrom
chenyangsu:fix/deepzoom-tile-size

Conversation

@chenyangsu

Copy link
Copy Markdown

DeepZoomGenerator.get_tile() can return tiles smaller than get_tile_dimensions() because PIL.Image.thumbnail() preserves the integer-rounded source region's aspect ratio. On tests/fixtures/boxes.tiff, get_tile(1, (0, 0)).size is (1, 1) instead of (2, 1), and get_tile(6, (0, 0)).size is (38, 31) instead of (38, 32). On multi-tile levels, edge tiles in one column get differing widths, departing from the Deep Zoom spec and libvips dzsave.

Using tile = tile.resize(z_size, ...) matches get_tile_dimensions() at every level, with tests. Happy to adjust the filter if you prefer.

Fixes #111

Testing: pytest -v (62 passed; 3 new fail on main), ruff and mypy clean.

Signed-off-by: Chen-Yang Su <cysu@stanford.edu>
@openslide-bot

Copy link
Copy Markdown
Member

DCO signed off ✔️

All commits have been signed off. You have certified to the terms of the Developer Certificate of Origin, version 1.1. In particular, you certify that this contribution has not been developed using information obtained under a non-disclosure agreement or other license terms that forbid you from contributing it under the GNU Lesser General Public License, version 2.1.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

deepzoom_tile.py creates tiles with inconsistent width or height

2 participants