diff --git a/sources/tiff/large_image_source_tiff/__init__.py b/sources/tiff/large_image_source_tiff/__init__.py index c47ef6cb1..b1fa379b0 100644 --- a/sources/tiff/large_image_source_tiff/__init__.py +++ b/sources/tiff/large_image_source_tiff/__init__.py @@ -277,6 +277,13 @@ def getTile(self, x, y, z, pilImageAllowed=False, numpyAllowed=False, sparseFallback=False, **kwargs): if z < 0: raise TileSourceException('z layer does not exist') + scale = 2 ** (self.levels - 1 - z) + offsetx = x * self.tileWidth * scale + if not (0 <= offsetx < self.sizeX): + raise TileSourceException('x is outside layer') + offsety = y * self.tileHeight * scale + if not (0 <= offsety < self.sizeY): + raise TileSourceException('y is outside layer') try: allowStyle = True if self._tiffDirectories[z] is None: