Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error reading and writing large gzip-compressed images #21

Closed
dyf opened this issue Oct 29, 2015 · 3 comments
Closed

error reading and writing large gzip-compressed images #21

dyf opened this issue Oct 29, 2015 · 3 comments

Comments

@dyf
Copy link

dyf commented Oct 29, 2015

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
Copy link
Owner

mhe commented Nov 1, 2015

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

mhe added a commit that referenced this issue Dec 20, 2015
This fixes issue #21. It does so by reading and writing data in chunks.
Another change is that the zlib module is now used instead of the gzip
module simplifing the code somewhat. Incidentally, this also fixes that
writing nrrd files with bzip2 encoding was broken.
@mhe
Copy link
Owner

mhe commented Dec 20, 2015

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.

@mhe mhe closed this as completed Dec 20, 2015
@dyf
Copy link
Author

dyf commented Dec 20, 2015

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//issues/21#issuecomment-166134607.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants