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

Multi-page tiff with a large amount of pages #3919

Closed
dsame89 opened this issue Jun 26, 2019 · 1 comment · Fixed by #3923
Closed

Multi-page tiff with a large amount of pages #3919

dsame89 opened this issue Jun 26, 2019 · 1 comment · Fixed by #3923
Labels
Projects

Comments

@dsame89
Copy link

dsame89 commented Jun 26, 2019

Hi,

I have a problem with multi-page tiff with over a 150 pages. Unable to do any operations on the pages over 150.

Image:
3 GB
2480x3508
300 dpi
Color dept: 24 bit
Compression LZW
222 pages in total

Code:

temp = Image.open("image.tiff") 
temp.seek(160)
temp.save("image2.tif")

Stacktrace:

Traceback (most recent call last):
  File "testarar.py", line 72, in <module>
    temp.save("image.tif")
  File "X/PIL/Image.py", line 1973, in save
    self._ensure_mutable()
  File "X/PIL/Image.py", line 628, in _ensure_mutable
    self._copy()
  File "X/PIL/Image.py", line 621, in _copy
    self.load()
  File "X/PIL/TiffImagePlugin.py", line 1077, in load
    return self._load_libtiff()
  File "X/PIL/TiffImagePlugin.py", line 1127, in _load_libtiff
    self.decoderconfig)
  File "X/PIL/Image.py", line 455, in _getdecoder
    return decoder(mode, *args + extra)
OverflowError: signed integer is greater than maximum
  • OS: Red Hat Enterprise Linux 7.6
  • Python: 3.6.3, 64bit
  • Pillow: Pillow-6.0.0.
@cgohlke
Copy link
Contributor

cgohlke commented Jun 27, 2019

I was able to reproduce this issue with a synthetic deflate compressed multi-page file.

PR #3923 should fix the OverflowError.

Another issue is that the file produced by Pillow is IEEEFP8, while the original image is UINT8, e.g.

TiffFile 'temp2.tif'  16.47 MiB

TiffPageSeries 0  2480x3508x3  float64  YXS  Generic  1 Pages

TiffPage 0 @17272310  2480x3508x3  ieeefp8  rgb adobe_deflate

TiffTag 254 NewSubfileType 1I @17272320  0
TiffTag 256 ImageWidth 1H @17272332  3508
TiffTag 257 ImageLength 1H @17272344  2480
TiffTag 258 BitsPerSample 3H @17272524  (8, 8, 8)
TiffTag 259 Compression 1H @17272368  ADOBE_DEFLATE
TiffTag 262 PhotometricInterpretation 1H @17272380  RGB
TiffTag 273 StripOffsets 1I @17272392  (8,)
TiffTag 277 SamplesPerPixel 1H @17272404  3
TiffTag 278 RowsPerStrip 1H @17272416  2480
TiffTag 279 StripByteCounts 1I @17272428  (17272301,)
TiffTag 282 XResolution 2I @17272508  (1, 1)
TiffTag 283 YResolution 2I @17272516  (1, 1)
TiffTag 284 PlanarConfiguration 1H @17272464  CONTIG
TiffTag 296 ResolutionUnit 1H @17272476  NONE
TiffTag 305 Software 12s @17272536  tifffile.py
TiffTag 339 SampleFormat 3H @17272530  ('IEEEFP', 'IEEEFP', 'IEEEFP')
TiffFile 'pillow_issue_3919.tif'  3.21 GiB   200 Pages

TiffPageSeries 0  200x2480x3508x3  uint8  IYXS  Uniform  200 Pages

TiffPage 0 @8  2480x3508x3  uint8  rgb adobe_deflate

TiffTag 254 NewSubfileType 1I @18  0
TiffTag 256 ImageWidth 1I @30  3508
TiffTag 257 ImageLength 1I @42  2480
TiffTag 258 BitsPerSample 3H @206  (8, 8, 8)
TiffTag 259 Compression 1H @66  ADOBE_DEFLATE
TiffTag 262 PhotometricInterpretation 1H @78  RGB
TiffTag 273 StripOffsets 414I @212  (3568, 45209, 86849, 128496, 170149, 211820
TiffTag 277 SamplesPerPixel 1H @102  3
TiffTag 278 RowsPerStrip 1I @114  6
TiffTag 279 StripByteCounts 414I @1868  (41641, 41640, 41647, 41653, 41671, 416
TiffTag 282 XResolution 2I @3524  (1, 1)
TiffTag 283 YResolution 2I @3532  (1, 1)
TiffTag 284 PlanarConfiguration 1H @162  CONTIG
TiffTag 296 ResolutionUnit 1H @174  NONE
TiffTag 305 Software 12s @3540  tifffile.py
TiffTag 339 SampleFormat 3H @3552  ('UINT', 'UINT', 'UINT')

Pillow automation moved this from Backlog to Closed Jun 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Pillow
  
Closed
Development

Successfully merging a pull request may close this issue.

3 participants