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

IOError: cannot identify image file '/path/to/Sample.tiff' with unknown Exif Tag #3372

Closed
ttback opened this issue Sep 21, 2018 · 6 comments
Closed
Labels

Comments

@ttback
Copy link

ttback commented Sep 21, 2018

What did you do?

I try to Image.open(tiff_path) on a 8-bit tiff image and got an error.

What did you expect to happen?

Image.open() is supposed to work on a 8-bit tiff image.

What actually happened?

Error from Pillow

  File "test.py", line 3, in <module>
    page=Image.open(path)
  File "/tmp/tiff/venv/local/lib/python2.7/site-packages/PIL/Image.py", line 2622, in open
    % (filename if filename else fp))
IOError: cannot identify image file '/path/to/Sample.tiff'

What are your OS, Python and Pillow versions?

  • OS: Debian 6.0
  • Python: Python 2.7
  • Pillow: Tried both legacy 2.9.0 and 5.2.0
from PIL import Image
path = "/Image/Sample.tiff"
page=Image.open(path)

The images are not public so I can't share them. But here are some imagemagick identify that may help.

Image that caused the error
Original image:

TIFF 3426x4378 3426x4378+0+0 1-bit Bilevel Gray 578044B 0.010u 0:00.009
unknown field with tag 32934 (0x80a6) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/704.

Processed image(resized without -strip)
TIFF 6669x6812 6669x6812+0+0 8-bit DirectClass 3.738MB 0.000u 0:00.000
A working image:
TIFF 5945x7399 5945x7399+0+0 8-bit DirectClass 4.952MB 0.000u 0:00.000

If there is any way to fix this image for Pillow loading, it would help as well.
Should unknown field with tag cause Pillow tiff loading issue?

@ttback ttback changed the title IOError: cannot identify image file '/path/to/Sample.tiff' IOError: cannot identify image file '/path/to/Sample.tiff' with unknown Exif Tag Sep 22, 2018
@radarhere radarhere added the TIFF label Sep 23, 2018
@radarhere
Copy link
Member

I have found https://upload.wikimedia.org/wikipedia/commons/f/f2/Yug-Shadedrelief.tmp.tif which identify shows as

Yug-Shadedrelief.tmp.tif TIFF 1980x773 1980x773+0+0 8-bit Grayscale Gray 1534380B 0.010u 0:00.009
identify: Unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/912.
identify: Unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/912.
identify: Unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/912.
identify: Unknown field with tag 34736 (0x87b0) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/912.
identify: Unknown field with tag 34737 (0x87b1) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/912.
identify: Unknown field with tag 42113 (0xa481) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/912.

That loads with error in Pillow. So ‘Unknown field with tag’ is not the cause of the issue.

I can also tell you that with https://github.com/python-pillow/Pillow/blob/master/Tests/images/g4-multi.tiff?raw=true, identify g4-multi.tiff shows

g4-multi.tiff[0] TIFF 3307x4677 3307x4677+0+0 1-bit Bilevel Gray 3275B 0.010u 0:00.000
g4-multi.tiff[1] TIFF 3307x4677 3307x4677+0+0 1-bit Bilevel Gray 3275B 0.000u 0:00.000
g4-multi.tiff[2] TIFF 3307x4677 3307x4677+0+0 1-bit Bilevel Gray 3275B 0.000u 0:00.000

So that looks similar to your image, and that loads fine.

It looks like more information is needed. I don’t suppose you could find other images from the same source, with the same error, that are able to be shared publicly?

Could you run identify -verbose over the file?

@ttback
Copy link
Author

ttback commented Sep 23, 2018

I will investigate more on Monday since I also couldn't reproduce this Pillow issue on my Mac machine with the tiff and same mogrify operation. Even though on the legacy code on Debian 6.0, mogrify -strip solves the problem, so it may be related to EXIF information somehow but it is unclear which field stripped may have caused the issue. I wonder if Pillow depends on libtiff for the tiff operations, maybe there was some bug in older libtiff. It is definitely odd because other images also had this " Unknown field with tag " issue and worked.

Here's the original tiff's identify -verbose using

Image: SAMPLE.tiff
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 3426x4378+0+0
  Resolution: 300x300
  Print size: 11.42x14.5933
  Units: PixelsPerInch
  Colorspace: Gray
  Type: Bilevel
  Endianess: LSB
  Depth: 1-bit
  Channel depth:
    Gray: 1-bit
  Channel statistics:
    Pixels: 14999028
    Gray:
      min: 0  (0)
      max: 1 (1)
      mean: 0.845678 (0.845678)
      standard deviation: 0.361257 (0.361257)
      kurtosis: 1.66243
      skewness: -1.91375
      entropy: 0.620552
  Colors: 2
  Histogram:
   2314682: (  0,  0,  0) #000000 gray(0)
  12684346: (255,255,255) #FFFFFF gray(255)
  Rendering intent: Undefined
  Gamma: 0.454545
  Matte color: grey74
  Background color: white
  Border color: srgb(223,223,223)
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 3426x4378+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: RLE
  Orientation: TopLeft
  Properties:
    date:create: 2018-09-22T10:51:24-04:00
    date:modify: 2018-09-22T10:51:03-04:00
    signature: {64-bit HASH}
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: min-is-white
    tiff:rows-per-strip: 73
    tiff:software: Oi/GFS, writer v00.06.00P, (c) Wang Labs, Inc. 1990, 1991
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 578044B
  Number pixels: 14.999M
  Pixels per second: 166.656MB
  User time: 0.070u
  Elapsed time: 0:01.090
  Version: ImageMagick 7.0.8-11 Q16 x86_64 2018-09-22 https://www.imagemagick.org
identify: Unknown field with tag 32934 (0x80a6) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/995.

@ttback
Copy link
Author

ttback commented Sep 25, 2018

The image with Debian imagemagick_8%3a6.6.0.4-3+squeeze3_amd64.deb(v 6.6.0.4-3) that bugs Pillow:

Image: buggy.tiff
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 5371x6812+0+0
  Resolution: 300x300
  Print size: 17.9033x22.7067
  Units: PixelsPerInch
  Type: PaletteAlpha
  Base type: TrueColorAlpha
  Endianess: LSB
  Colorspace: sRGB
  Depth: 8/1-bit
  Channel depth:
    Red: 1-bit
    Green: 1-bit
    Blue: 1-bit
    Alpha: 1-bit
  Channel statistics:
    Pixels: 36587252
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 215.974 (0.846956)
      standard deviation: 91.8075 (0.360029)
      kurtosis: 1.71479
      skewness: -1.92738
      entropy: 0.617405
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 214.075 (0.839509)
      standard deviation: 93.6005 (0.367061)
      kurtosis: 1.42205
      skewness: -1.84988
      entropy: 0.635483
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 214.075 (0.839509)
      standard deviation: 93.6005 (0.367061)
      kurtosis: 1.42205
      skewness: -1.84988
      entropy: 0.635483
    Alpha:
      min: 0 (0)
      max: 255 (1)
      mean: 253.101 (0.992553)
      standard deviation: 21.924 (0.0859764)
      kurtosis: 129.283
      skewness: -11.4579
      entropy: 0.0633503
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 224.306 (0.879632)
      standard deviation: 82.9749 (0.325392)
      kurtosis: 3.44468
      skewness: -2.33338
      entropy: 0.48793
  Alpha: srgba(255,0,0,0)   #FF000000
  Colors: 3
  Histogram:
   5599443: (  0,  0,  0,255) #000000FF black
    272480: (255,  0,  0,  0) #FF000000 srgba(255,0,0,0)
  30715329: (255,255,255,255) #FFFFFFFF white
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Matte color: grey74
  Background color: white
  Border color: srgb(223,223,223)
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 5371x6812+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: LZW
  Orientation: TopLeft
  Properties:
    date:create: 2018-09-25T11:40:26-04:00
    date:modify: 2018-09-25T11:40:26-04:00
    signature: {64-bit hash}
    tiff:alpha: unassociated
    tiff:document: img_dir/buggy.tiff
    tiff:endian: lsb
    tiff:photometric: RGB
    tiff:rows-per-strip: 1
    tiff:software: ImageMagick 6.6.0-4 2012-05-02 Q16 http://www.imagemagick.org
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 3.19609MiB
  Number pixels: 36.5873M
  Pixels per second: 13.353MB
  User time: 1.600u
  Elapsed time: 0:03.739
  Version: ImageMagick 7.0.7-1 Q16 x86_64 2017-09-13 http://www.imagemagick.org

Good image generated by ImageMagick 6.9.10-12 Q16 x86_64 2018-09-25 https://imagemagick.org

Image: good.tiff
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 5371x6812+0+0
  Resolution: 300x300
  Print size: 17.9033x22.7067
  Units: PixelsPerInch
  Type: PaletteAlpha
  Base type: TrueColorAlpha
  Endianess: LSB
  Colorspace: sRGB
  Depth: 8/1-bit
  Channel depth:
    Red: 1-bit
    Green: 1-bit
    Blue: 1-bit
    Alpha: 1-bit
  Channel statistics:
    Pixels: 36587252
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 215.974 (0.846955)
      standard deviation: 91.8078 (0.360031)
      kurtosis: 1.71473
      skewness: -1.92736
      entropy: 0.617408
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 214.074 (0.839508)
      standard deviation: 93.6008 (0.367062)
      kurtosis: 1.422
      skewness: -1.84987
      entropy: 0.635486
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 214.074 (0.839508)
      standard deviation: 93.6008 (0.367062)
      kurtosis: 1.422
      skewness: -1.84987
      entropy: 0.635486
    Alpha:
      min: 0 (0)
      max: 255 (1)
      mean: 253.101 (0.992553)
      standard deviation: 21.924 (0.0859764)
      kurtosis: 129.283
      skewness: -11.4579
      entropy: 0.0633503
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 224.306 (0.879631)
      standard deviation: 82.9752 (0.325393)
      kurtosis: 3.44462
      skewness: -2.33337
      entropy: 0.487932
  Alpha: srgba(255,0,0,0)   #FF000000
  Colors: 3
  Histogram:
   5599490: (  0,  0,  0,255) #000000FF black
    272480: (255,  0,  0,  0) #FF000000 srgba(255,0,0,0)
  30715282: (255,255,255,255) #FFFFFFFF white
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Matte color: grey74
  Background color: white
  Border color: srgb(223,223,223)
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 5371x6812+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: LZW
  Orientation: TopLeft
  Properties:
    date:create: 2018-09-25T12:05:14-04:00
    date:modify: 2018-09-25T12:05:14-04:00
    signature: {hash}
    tiff:alpha: unassociated
    tiff:endian: lsb
    tiff:photometric: RGB
    tiff:rows-per-strip: 6812
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 1643810B
  Number pixels: 36.5873M
  Pixels per second: 20.3263MB
  User time: 1.480u
  Elapsed time: 0:02.799
  Version: ImageMagick 7.0.7-1 Q16 x86_64 2017-09-13 http://www.imagemagick.org

@ttback
Copy link
Author

ttback commented Sep 26, 2018

The custom properties in the bug.tiff seems to be
tiff:document:
tiff:software: ImageMagick 6.6.0-4 2012-05-02 Q16 http://
I don't know if those metadata would affect Pillow

@radarhere
Copy link
Member

Okay, to get a better look at this, would you mind making this change to your copy of Pillow, and letting us know what error is raised then?

tiff

You can also download this from https://github.com/radarhere/Pillow/tree/tiff_test if you want, with the commit radarhere@940b002

@radarhere
Copy link
Member

Closing due to lack of response. Feel free to comment again and this can be re-opened.

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

No branches or pull requests

2 participants