From ea1e965adc8db66cab6d65a2423a7b4a49cb93c5 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Wed, 27 Apr 2022 09:16:17 -0400 Subject: [PATCH] Improve handling for vips format. By default pyvips.black can't be copied to a different format, but must be cast. --- sources/vips/large_image_source_vips/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/vips/large_image_source_vips/__init__.py b/sources/vips/large_image_source_vips/__init__.py index 1bdd7a245..5c308004c 100644 --- a/sources/vips/large_image_source_vips/__init__.py +++ b/sources/vips/large_image_source_vips/__init__.py @@ -395,6 +395,8 @@ def _outputToImage(self): xres=1.0 / (self.mm_x if self.mm_x else self._mm_y), yres=1.0 / (self.mm_y if self.mm_y else self._mm_x)) format = self._getVipsFormat() + if img.format != format: + img = img.cast(format) baseimg = img.copy(interpretation=self._output['interp'], format=format) leaves = math.ceil(len(self._output['images']) ** (1. / 3))