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

Unable to read 16bit tiff #1828

Closed
johnscancella opened this issue Apr 12, 2016 · 4 comments
Closed

Unable to read 16bit tiff #1828

johnscancella opened this issue Apr 12, 2016 · 4 comments

Comments

@johnscancella
Copy link

What did you do?

im = Image.open("afc1981004_046_02.tif")

What did you expect to happen?

It opens the tiff

What actually happened?

it threw an error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jscancella/development/repos/derivative-scripts/ENV2/lib/python3.5/site-packages/PIL/Image.py", line 2309, in open
    % (filename if filename else fp))
OSError: cannot identify image file <_io.StringIO object at 0x100a35dc8>

What versions of Pillow and Python are you using?

3.2.0

Please include code that reproduces the issue and whenever possible, an image that demonstrates the issue. The best reproductions are self-contained scripts with minimal dependencies.

unfortunately it won't let me upload the file, but I would be happy to send it to you in an email.

from PIL import Image
im = Image.open("afc1981004_046_02.tif")

output of identify

[jscancella]$ identify -verbose afc1981004_046_02.tiff
Image: /Users/jscancella/work/images/afc1981004_046_02.tiff
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 5046x3426+0+0
  Resolution: 3600x3600
  Print size: 1.40167x0.951667
  Units: PixelsPerInch
  Type: TrueColor
  Base type: TrueColor
  Endianess: LSB
  Colorspace: sRGB
  Depth: 16-bit
  Channel depth:
    red: 16-bit
    green: 16-bit
    blue: 16-bit
  Channel statistics:
    Pixels: 17287596
    Red:
      min: 5989 (0.0913863)
      max: 65535 (1)
      mean: 13145.6 (0.200588)
      standard deviation: 9808.18 (0.149663)
      kurtosis: 4.09231
      skewness: 2.05007
      entropy: 0.877932
    Green:
      min: 6291 (0.0959945)
      max: 65535 (1)
      mean: 13471.8 (0.205566)
      standard deviation: 10479.2 (0.159902)
      kurtosis: 3.88293
      skewness: 2.05712
      entropy: 0.859453
    Blue:
      min: 135 (0.00205997)
      max: 65055 (0.992676)
      mean: 14642.6 (0.223432)
      standard deviation: 12033.2 (0.183615)
      kurtosis: 2.73516
      skewness: 1.87165
      entropy: 0.887947
  Image statistics:
    Overall:
      min: 135 (0.00205997)
      max: 65535 (1)
      mean: 13753.3 (0.209862)
      standard deviation: 10813.7 (0.165007)
      kurtosis: 3.68086
      skewness: 2.02482
      entropy: 0.875111
  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)
  Background color: white
  Border color: srgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 5046x3426+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 0 of 2
  Compression: None
  Orientation: TopLeft
  Properties:
    date:create: 2016-04-12T12:33:10-04:00
    date:modify: 2016-04-12T12:25:42-04:00
    exif:DateTimeDigitized: 2015:06:10 16:50:56
    exif:DateTimeOriginal: 2015:06:10 16:50:56
    exif:ISOSpeedRatings: 35
    exif:LightSource: 255
    signature: 920180f74560c61b2ccea659d3d8ae4d4479fe351350e905be2784812dc57e09
    tiff:alpha: unspecified
    tiff:artist: Library of Congress;Backstage Library Works
    tiff:endian: lsb
    tiff:make: Phase One
    tiff:model: IQ180
    tiff:photometric: RGB
    tiff:rows-per-strip: 1024
    tiff:software: Capture One 8 Windows
    tiff:timestamp: 2015:07:28 20:13:56
  Profiles:
    Profile-icc: 544 bytes
    Profile-iptc: 36 bytes
      unknown[1,0]:
      City[1,90]: 0x00000000: 254700                                        -%
      unknown[2,0]:
      Created Date[2,55]: 20150610
  Artifacts:
    filename: /Users/jscancella/work/images/afc1981004_046_02.tiff
    verbose: true
  Tainted: False
  Filesize: 103.8MB
  Number pixels: 17.29M
  Pixels per second: 1.08047TB
  User time: 0.000u
  Elapsed time: 0:01.000
  Version: ImageMagick 6.9.2-8 Q16 x86_64 2015-12-06 http://www.imagemagick.org
Image: /Users/jscancella/work/images/afc1981004_046_02.tiff
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 160x109+0+0
  Units: PixelsPerInch
  Type: TrueColor
  Base type: TrueColor
  Endianess: LSB
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Pixels: 17440
    Red:
      min: 20 (0.0784314)
      max: 247 (0.968627)
      mean: 51.9957 (0.203905)
      standard deviation: 35.564 (0.139467)
      kurtosis: 3.9248
      skewness: 1.93113
      entropy: 0.77921
    Green:
      min: 24 (0.0941176)
      max: 252 (0.988235)
      mean: 53.4612 (0.209652)
      standard deviation: 38.129 (0.149525)
      kurtosis: 3.28637
      skewness: 1.86889
      entropy: 0.748883
    Blue:
      min: 21 (0.0823529)
      max: 255 (1)
      mean: 57.9004 (0.22706)
      standard deviation: 44.4001 (0.174118)
      kurtosis: 2.62465
      skewness: 1.78744
      entropy: 0.793156
  Image statistics:
    Overall:
      min: 20 (0.0784314)
      max: 255 (1)
      mean: 54.4524 (0.213539)
      standard deviation: 39.5389 (0.155055)
      kurtosis: 3.45284
      skewness: 1.90731
      entropy: 0.77375
  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)
  Background color: white
  Border color: srgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 160x109+0+0
  Dispose: Undefined
  Iterations: 0
  Scene: 1 of 2
  Compression: None
  Orientation: TopLeft
  Properties:
    date:create: 2016-04-12T12:33:10-04:00
    date:modify: 2016-04-12T12:25:42-04:00
    signature: 0020992c1769fa75d5b8286edb6b1256a35cd7a1d4cb77c960b5cc26b95bd87e
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: RGB
    tiff:rows-per-strip: 17
    tiff:subfiletype: REDUCEDIMAGE
  Artifacts:
    filename: /Users/jscancella/work/images/afc1981004_046_02.tiff
    verbose: true
  Tainted: False
  Filesize: 103.8MB
  Number pixels: 17.4K
  Pixels per second: 169.3MB
  User time: 0.000u
  Elapsed time: 0:01.000
  Version: ImageMagick 6.9.2-8 Q16 x86_64 2015-12-06 http://www.imagemagick.org
identify: Wrong data type 3 for "PixelXDimension"; tag ignored. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/887.
identify: Wrong data type 3 for "PixelYDimension"; tag ignored. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/887.
identify: Incompatible type for "FileSource"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/887.
identify: Incompatible type for "SceneType"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/887.
@wiredfool
Copy link
Member

Sorry, it's a limitation of Pillow. We don't have the ability to read multichannel images that are more than 8 bit per channel.

@acdha
Copy link
Contributor

acdha commented Apr 12, 2016

@wiredfool Did that change over time? I was under the impression that it was intended to be supported but there were gaps for some of the option permutations.

@wiredfool
Copy link
Member

It's never been supported. (at least, back to PIL 1.1.6)

There are two core image representations, 8bpp and 32bpp. The 8 can be used in several ways, each single channel, and the 32 can be used as either 4 8 bit channels or 1 16 or 32 bit channel. These are defined in libImaging/Storage.c

Apart from that, there are many image formats that mapped onto those 8 or 32bit pixels, but they're a mapping, not a bit copy. (e.g., mode 1 images, black and white, are represented as 8 bits per pixel, 0 or 255). These are defined in libImaging/Unpack.c and libImaging/Pack.c.

There was someone interested in doing the work to add multi-channel high bit depth images, but that fell through for time or funding reasons.

@wiredfool
Copy link
Member

Closing, see #1888 for potential future developments

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

3 participants