def read_window(self, region, out_width, out_height, c: Optional[Union[int, List[int]]] = None, **other): tier = self.format.pyramid.most_appropriate_tier( region, (out_width, out_height)) region = region.scale_to_tier(tier) page = tier.data.get('page_index') tiff_page = VIPSImage.jp2kload(str(self.format.path), page=page) im = tiff_page.extract_area(region.left, region.top, region.width, region.height) return self._extract_channels(im, c)
def read_tile(self, tile, c: Optional[Union[int, List[int]]] = None, **other): tier = tile.tier page = tier.data.get('page_index') tiff_page = VIPSImage.jp2kload(str(self.format.path), page=page) # There is no direct access to underlying tiles in vips # But the following computation match vips implementation so that only the tile # that has to be read is read. # https://github.com/jcupitt/tilesrv/blob/master/tilesrv.c#L461 # TODO: is direct tile access significantly faster ? im = tiff_page.extract_area(tile.left, tile.top, tile.width, tile.height) return self._extract_channels(im, c)