Skip to content

Commit

Permalink
Fix byte order when reading from big-endian formats
Browse files Browse the repository at this point in the history
  • Loading branch information
jmuhlich committed Nov 24, 2024
1 parent 2e56dc4 commit 4027581
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ashlar/reg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4027581

Please sign in to comment.