From 63d799e9cf0b12ffa37fa83fe3c48c5e35024f56 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Tue, 20 Dec 2022 12:54:50 -0500 Subject: [PATCH] Better output new vips images as float32. When asking to output vips images as float32, they were being promoted to float64. --- CHANGELOG.md | 3 +++ sources/vips/large_image_source_vips/__init__.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72caa6930..b23e3b8ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ ### Changes - Don't report filename in internal PIL metadata ([#1006](../../pull/1006)) +### Bug Fixes +- Better output new vips images as float32 ([#1016](../../pull/1016)) + ## 1.18.0 ### Features diff --git a/sources/vips/large_image_source_vips/__init__.py b/sources/vips/large_image_source_vips/__init__.py index 1e1138365..d983f8edf 100644 --- a/sources/vips/large_image_source_vips/__init__.py +++ b/sources/vips/large_image_source_vips/__init__.py @@ -420,8 +420,11 @@ def _outputToImage(self): trunk = baseimg.copy() branch = baseimg.copy() for idx, entry in enumerate(self._output['images']): + entryimage = entry['image'] + if img.format == 'float' and entry['image'].format == 'double': + entryimage = entryimage.cast(img.format) branch = branch.composite( - entry['image'], pyvips.BlendMode.OVER, x=entry['x'], y=entry['y']) + entryimage, pyvips.BlendMode.OVER, x=entry['x'], y=entry['y']) if not ((idx + 1) % leaves) or idx + 1 == len(self._output['images']): trunk = trunk.composite(branch, pyvips.BlendMode.OVER, x=0, y=0) branch = baseimg.copy()