Skip to content

Commit b72823e

Browse files
committed
deepzoom: Change default tile size to 254 pixels
For best viewer performance, the total tile size including overlaps should be a power of 2: https://github.com/jcupitt/libvips/pull/359#issuecomment-166433497 https://github.com/jcupitt/libvips/pull/359#issuecomment-166440011 https://github.com/jcupitt/libvips/pull/359#issuecomment-166686550
1 parent 258f339 commit b72823e

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

doc/index.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,15 @@ Deep Zoom or a similar format.
253253

254254
.. _`Deep Zoom`: http://msdn.microsoft.com/en-us/library/cc645050%28VS.95%29.aspx
255255

256-
.. class:: DeepZoomGenerator(osr, tile_size=256, overlap=1, limit_bounds=False)
256+
.. class:: DeepZoomGenerator(osr, tile_size=254, overlap=1, limit_bounds=False)
257257

258258
A Deep Zoom generator that wraps an
259259
:class:`OpenSlide <openslide.OpenSlide>` or
260260
:class:`ImageSlide <openslide.ImageSlide>` object.
261261

262262
:param osr: the slide object
263-
:param int tile_size: the width and height of a single tile
263+
:param int tile_size: the width and height of a single tile. For best
264+
viewer performance, ``tile_size + 2 * overlap`` should be a power of two.
264265
:param int overlap: the number of extra pixels to add to each interior edge
265266
of a tile
266267
:param bool limit_bounds: ``True`` to render only the non-empty slide

examples/deepzoom/deepzoom_multiserver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
SLIDE_DIR = '.'
3232
SLIDE_CACHE_SIZE = 10
3333
DEEPZOOM_FORMAT = 'jpeg'
34-
DEEPZOOM_TILE_SIZE = 256
34+
DEEPZOOM_TILE_SIZE = 254
3535
DEEPZOOM_OVERLAP = 1
3636
DEEPZOOM_LIMIT_BOUNDS = True
3737
DEEPZOOM_TILE_QUALITY = 75
@@ -194,7 +194,7 @@ def tile(path, level, col, row, format):
194194
help='JPEG compression quality [75]')
195195
parser.add_option('-s', '--size', metavar='PIXELS',
196196
dest='DEEPZOOM_TILE_SIZE', type='int',
197-
help='tile size [256]')
197+
help='tile size [254]')
198198

199199
(opts, args) = parser.parse_args()
200200
# Load config file if specified

examples/deepzoom/deepzoom_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
DEEPZOOM_SLIDE = None
3131
DEEPZOOM_FORMAT = 'jpeg'
32-
DEEPZOOM_TILE_SIZE = 256
32+
DEEPZOOM_TILE_SIZE = 254
3333
DEEPZOOM_OVERLAP = 1
3434
DEEPZOOM_LIMIT_BOUNDS = True
3535
DEEPZOOM_TILE_QUALITY = 75
@@ -149,7 +149,7 @@ def slugify(text):
149149
help='JPEG compression quality [75]')
150150
parser.add_option('-s', '--size', metavar='PIXELS',
151151
dest='DEEPZOOM_TILE_SIZE', type='int',
152-
help='tile size [256]')
152+
help='tile size [254]')
153153

154154
(opts, args) = parser.parse_args()
155155
# Load config file if specified

examples/deepzoom/deepzoom_tile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ def _shutdown(self):
254254
action='store_true',
255255
help='generate directory tree with HTML viewer')
256256
parser.add_option('-s', '--size', metavar='PIXELS', dest='tile_size',
257-
type='int', default=256,
258-
help='tile size [256]')
257+
type='int', default=254,
258+
help='tile size [254]')
259259

260260
(opts, args) = parser.parse_args()
261261
try:

openslide/deepzoom.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ class DeepZoomGenerator(object):
3838
BOUNDS_SIZE_PROPS = (openslide.PROPERTY_NAME_BOUNDS_WIDTH,
3939
openslide.PROPERTY_NAME_BOUNDS_HEIGHT)
4040

41-
def __init__(self, osr, tile_size=256, overlap=1, limit_bounds=False):
41+
def __init__(self, osr, tile_size=254, overlap=1, limit_bounds=False):
4242
"""Create a DeepZoomGenerator wrapping an OpenSlide object.
4343
4444
osr: a slide object.
45-
tile_size: the width and height of a single tile.
45+
tile_size: the width and height of a single tile. For best viewer
46+
performance, tile_size + 2 * overlap should be a power
47+
of two.
4648
overlap: the number of extra pixels to add to each interior edge
4749
of a tile.
4850
limit_bounds: True to render only the non-empty slide region."""

0 commit comments

Comments
 (0)