mhe / pynrrd

Simple pure-python module for reading and writing nrrd files.
https://pynrrd.readthedocs.io/
MIT License
116 stars 51 forks source link

error reading and writing large gzip-compressed images #21

Closed dyf closed 8 years ago

dyf commented 9 years ago

When reading and writing images with gzip compression, the gzip library does a 32-bit CRC check. This fails when the image array is larger than what can be represented with 32-bit precision.

Here's the traceback for reading:

Traceback (most recent call last): File "run_all_image_series.py", line 60, in if name == "main": main() File "run_all_image_series.py", line 53, in main density, meta = nrrd.read( density_file ) File "/shared/utils.x86_64/python-2.7/lib/python2.7/site-packages/nrrd.py", line 366, in read data = read_data(header, filehandle, filename) File "/shared/utils.x86_64/python-2.7/lib/python2.7/site-packages/nrrd.py", line 264, in read_data data = np.fromstring(gzipfile.read(), dtype) File "/shared/utils.x86_64/python-2.7/lib/python2.7/gzip.py", line 261, in read self._read(readsize) File "/shared/utils.x86_64/python-2.7/lib/python2.7/gzip.py", line 320, in _read self._add_read_data( uncompress ) File "/shared/utils.x86_64/python-2.7/lib/python2.7/gzip.py", line 336, in _add_read_data self.crc = zlib.crc32(data, self.crc) & 0xffffffffL OverflowError: size does not fit in an int

A very similar error occurs on write.

mhe commented 9 years ago

Interesting, thanks for reporting. I'm not yet sure how to resolve this.

mhe commented 8 years ago

It turns out resolving this was not too hard. I'll wait a few days before doing a version bump on PyPi. @dyf, thanks again for reporting.

dyf commented 8 years ago

That's great, thanks!

On Dec 20, 2015 8:47 AM, Maarten Everts notifications@github.com wrote:

It turns out resolving this was not too hard. I'll wait a few days before doing a version bump on PyPi. @dyfhttps://github.com/dyf, thanks again for reporting.

Reply to this email directly or view it on GitHubhttps://github.com/mhe/pynrrd/issues/21#issuecomment-166134607.