From acaea97c5d7efff07a8e53cef6758f052c912f69 Mon Sep 17 00:00:00 2001 From: LukasMicroscopy Date: Tue, 25 Mar 2025 15:20:14 +0100 Subject: [PATCH] bugfix tiff tag bits per sample, byte_depth assignment --- python/ndstorage/ndtiff_file.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/python/ndstorage/ndtiff_file.py b/python/ndstorage/ndtiff_file.py index 5fcac31..2743b51 100644 --- a/python/ndstorage/ndtiff_file.py +++ b/python/ndstorage/ndtiff_file.py @@ -172,7 +172,16 @@ def _write_ifd(self, index_key, pixels, metadata, rgb, image_height, image_width if self.file.tell() % 2 == 1: self.file.seek(self.file.tell() + 1) # Make IFD start on word - byte_depth = 1 if isinstance(pixels, bytearray) else 2 + if isinstance(pixels, bytearray): + byte_depth = 1 + # if the pixel object is a numpy array, it is type of + # when using np_array.tobytes it is + # therefore taking the the bit_depth information "pixels.dtype" into account + elif bit_depth == 8: + byte_depth = 1 + else: + byte_depth = 2 + bytes_per_image_pixels = self._bytes_per_image_pixels(pixels, rgb) num_entries = 13