From 4027581295aa8786f81c2a898fb42962ef3c7214 Mon Sep 17 00:00:00 2001 From: Jeremy Muhlich Date: Sun, 24 Nov 2024 18:32:17 -0500 Subject: [PATCH] Fix byte order when reading from big-endian formats --- ashlar/reg.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ashlar/reg.py b/ashlar/reg.py index 351edfa7..1276c961 100644 --- a/ashlar/reg.py +++ b/ashlar/reg.py @@ -404,7 +404,8 @@ def read(self, series, c): self.metadata._reader.setSeries(self.metadata.active_series[series]) index = self.metadata._reader.getIndex(0, c, 0) byte_array = self.metadata._reader.openBytes(index) - dtype = self.metadata.pixel_dtype + endian = "<" if self.metadata._reader.isLittleEndian() else ">" + dtype = self.metadata.pixel_dtype.newbyteorder(endian) shape = self.metadata.tile_size(series) img = np.frombuffer(byte_array.tostring(), dtype=dtype).reshape(shape) return img