Dan, My point was also, that I would doubt that there is physically(!) more information than 16e6 possible values per pixel. A digital gray scale CCD camera with more than 12 bits costs multiple 1000s of Euros or Dollars...
Maybe you could use imagemagick to convert 1 16bit RGB into 3 16bit gray images and read those into PIL. Can I ask what your overall intend with all of this is ? Cheers, Sebastian On Mon, Apr 12, 2010 at 1:42 PM, Dan Blacker <dan.blac...@googlemail.com> wrote: > Hi Sebastian, > > Yes I am scanning film and need to retain the as much of the color > information as possble, so 16bit is essential. > > Could I perhaps do a convert with imagemagick - that would turn it into a > 16bit tif file that PIL could read properly? > > Cheers, > Dan > > > > > > On 12 April 2010 12:32, Sebastian Haase <seb.ha...@gmail.com> wrote: >> >> Hi, >> >> are you sure it makes even sense to save a 16-bit RGB image ? This is >> not meant as an excuse for PIL to not support it, >> but 16mio colors should likely be enough for any application (i.e. >> 8bit per R,G and B) >> >> Regards, >> Sebastian Haase >> >> >> On Mon, Apr 12, 2010 at 10:33 AM, Dan Blacker >> <dan.blac...@googlemail.com> wrote: >> > Hi Sebastian, >> > >> > Thanks so much for having a look at this, >> > >> > The image file is actually from an Epson v700 scanner, scanned using >> > Vuescan >> > in Ubuntu. >> > >> > It is an RGB image, not a grayscale one. >> > >> > Do you think I will be able to use this image with PIL? WIll I need to >> > patch >> > my version? >> > >> > Thanks again, >> > Dan >> > >> > >> > >> > >> > >> > On 12 April 2010 08:37, Sebastian Haase <seb.ha...@gmail.com> wrote: >> >> >> >> Hi Dan, >> >> >> >> I'm running a patched version of PIL 1.1.6 and could open all (I >> >> thought) 16-bit TIF images in the past. >> >> But with yours I also got >> >> IOError("cannot identify image file") >> >> >> >> To find out what the problem is I used ImageMagick >> >> $: identify Download/16_bit_example.tif >> >> Download/16_bit_example.tif TIFF 318x336 318x336+0+0 16-bit >> >> DirectClass 645KB 0.000u 0:00.010 >> >> >> >> So far this look fine. >> >> But trying to use PIL's TIF module directly, I find: >> >> >>> import TiffImagePlugin >> >> >>> fp = open("/home/shaase/Download/16_bit_example.tif") >> >> >>> >> >> >>> >> >> >>> TiffImagePlugin.TiffImageFile(fp,"/home/shaase/Download/16_bit_example.tif") >> >> Traceback (most recent call last): >> >> File "<input>", line 1, in <module> >> >> File "./PIL/ImageFile.py", line 82, in __init__ >> >> self._open() >> >> File "./PIL/TiffImagePlugin.py", line 507, in _open >> >> self._seek(0) >> >> File "./PIL/TiffImagePlugin.py", line 535, in _seek >> >> self._setup() >> >> File "./PIL/TiffImagePlugin.py", line 613, in _setup >> >> raise SyntaxError, "unknown pixel mode" >> >> >>> pdb.pm() >> >> (Pdb) p key >> >> ('l', 2, 1, 1, (16, 16, 16), ()) >> >> >> >> Aha, PIL thinks it's an 16-bit RGB image - i.e. not grayscale. >> >> Is this correct ? >> >> >> >> Just for reference, I will paste my list of recognized "key"s below, >> >> maybe someone knows what line would have to be added to support your >> >> file. >> >> >> >> Cheers, >> >> Sebastian Haase >> >> >> >> PS: Did you get this file by any chance from a Zeiss Microscope LSM >> >> image ? - I just saw that I tried this in the past ... >> >> >> >> <code from patched 1.1.6 >> >> >> >> >> >> TiffImagePlugin.py----------------------------------------------------------------------------------> >> >> >> >> OPEN_INFO = { >> >> # (ByteOrder, PhotoInterpretation, SampleFormat, FillOrder, >> >> BitsPerSample, >> >> # ExtraSamples) => mode, rawmode >> >> ('l', 0, 1, 1, (1,), ()): ("1", "1;I"), >> >> ('l', 0, 1, 2, (1,), ()): ("1", "1;IR"), >> >> ('l', 0, 1, 1, (8,), ()): ("L", "L;I"), >> >> ('l', 0, 1, 2, (8,), ()): ("L", "L;IR"), >> >> ('l', 1, 1, 1, (1,), ()): ("1", "1"), >> >> ('l', 1, 1, 2, (1,), ()): ("1", "1;R"), >> >> ('l', 1, 1, 1, (8,), ()): ("L", "L"), >> >> ('l', 1, 1, 1, (8,8), (2,)): ("LA", "LA"), >> >> ('l', 1, 1, 2, (8,), ()): ("L", "L;R"), >> >> ('l', 1, 1, 1, (16,), ()): ("I;16", "I;16"), >> >> ('l', 1, 2, 1, (16,), ()): ("I;16S", "I;16S"), >> >> ('l', 1, 2, 1, (32,), ()): ("I", "I;32S"), >> >> ('l', 1, 3, 1, (32,), ()): ("F", "F;32F"), >> >> ('l', 2, 1, 1, (8,8,8), ()): ("RGB", "RGB"), >> >> ('l', 2, 1, 1, (8,8,0), ()): ("RGB", "RGB"),#seb -- found in >> >> LSM(Zeiss) files >> >> #('l', 2, 1, 1, (16,16,16), ()): ("RGB", "RGB"),#seb -- found in >> >> LSM(Zeiss) files >> >> ('l', 2, 1, 2, (8,8,8), ()): ("RGB", "RGB;R"), >> >> #seb jeff's ('l', 2, 1, 1, (8,8,8,8), ()): ("RGBX", "RGBX"),#seb >> >> -- found in LSM(Zeiss) files >> >> ('l', 2, 1, 1, (8,8,8,8), (0,)): ("RGBX", "RGBX"), >> >> ('l', 2, 1, 1, (8,8,8,8), (1,)): ("RGBA", "RGBa"), >> >> ('l', 2, 1, 1, (8,8,8,8), (2,)): ("RGBA", "RGBA"), >> >> ('l', 2, 1, 1, (8,8,8,8), (999,)): ("RGBA", "RGBA"), # corel draw 10 >> >> ('l', 3, 1, 1, (1,), ()): ("P", "P;1"), >> >> ('l', 3, 1, 2, (1,), ()): ("P", "P;1R"), >> >> ('l', 3, 1, 1, (2,), ()): ("P", "P;2"), >> >> ('l', 3, 1, 2, (2,), ()): ("P", "P;2R"), >> >> ('l', 3, 1, 1, (4,), ()): ("P", "P;4"), >> >> ('l', 3, 1, 2, (4,), ()): ("P", "P;4R"), >> >> ('l', 3, 1, 1, (8,), ()): ("P", "P"), >> >> ('l', 3, 1, 1, (8,8), (2,)): ("PA", "PA"), >> >> ('l', 3, 1, 2, (8,), ()): ("P", "P;R"), >> >> ('l', 5, 1, 1, (8,8,8,8), ()): ("CMYK", "CMYK"), >> >> ('l', 6, 1, 1, (8,8,8), ()): ("YCbCr", "YCbCr"), >> >> ('l', 8, 1, 1, (8,8,8), ()): ("LAB", "LAB"), >> >> >> >> ('b', 0, 1, 1, (1,), ()): ("1", "1;I"), >> >> ('b', 0, 1, 2, (1,), ()): ("1", "1;IR"), >> >> ('b', 0, 1, 1, (8,), ()): ("L", "L;I"), >> >> ('b', 0, 1, 2, (8,), ()): ("L", "L;IR"), >> >> ('b', 1, 1, 1, (1,), ()): ("1", "1"), >> >> ('b', 1, 1, 2, (1,), ()): ("1", "1;R"), >> >> ('b', 1, 1, 1, (8,), ()): ("L", "L"), >> >> ('b', 1, 1, 1, (8,8), (2,)): ("LA", "LA"), >> >> ('b', 1, 1, 2, (8,), ()): ("L", "L;R"), >> >> ('b', 1, 1, 1, (16,), ()): ("I;16B", "I;16B"), >> >> ('b', 1, 2, 1, (16,), ()): ("I;16BS", "I;16BS"), >> >> ('b', 1, 2, 1, (32,), ()): ("I;32BS", "I;32BS"), >> >> ('b', 1, 3, 1, (32,), ()): ("F;32BF", "F;32BF"), >> >> ('b', 2, 1, 1, (8,8,8), ()): ("RGB", "RGB"), >> >> ('b', 2, 1, 2, (8,8,8), ()): ("RGB", "RGB;R"), >> >> ('b', 2, 1, 1, (8,8,8,8), (0,)): ("RGBX", "RGBX"), >> >> ('b', 2, 1, 1, (8,8,8,8), (1,)): ("RGBA", "RGBa"), >> >> ('b', 2, 1, 1, (8,8,8,8), (2,)): ("RGBA", "RGBA"), >> >> ('b', 2, 1, 1, (8,8,8,8), (999,)): ("RGBA", "RGBA"), # corel draw 10 >> >> ('b', 3, 1, 1, (1,), ()): ("P", "P;1"), >> >> ('b', 3, 1, 2, (1,), ()): ("P", "P;1R"), >> >> ('b', 3, 1, 1, (2,), ()): ("P", "P;2"), >> >> ('b', 3, 1, 2, (2,), ()): ("P", "P;2R"), >> >> ('b', 3, 1, 1, (4,), ()): ("P", "P;4"), >> >> ('b', 3, 1, 2, (4,), ()): ("P", "P;4R"), >> >> ('b', 3, 1, 1, (8,), ()): ("P", "P"), >> >> ('b', 3, 1, 1, (8,8), (2,)): ("PA", "PA"), >> >> ('b', 3, 1, 2, (8,), ()): ("P", "P;R"), >> >> ('b', 5, 1, 1, (8,8,8,8), ()): ("CMYK", "CMYK"), >> >> ('b', 6, 1, 1, (8,8,8), ()): ("YCbCr", "YCbCr"), >> >> ('b', 8, 1, 1, (8,8,8), ()): ("LAB", "LAB"), >> >> } >> >> </code from patched 1.1.6 >> >> >> >> >> >> TiffImagePlugin.py----------------------------------------------------------------------------------> >> >> >> >> >> >> >> >> On Sat, Apr 10, 2010 at 6:08 PM, Dan Blacker >> >> <dan.blac...@googlemail.com> >> >> wrote: >> >> > Hello, I wonder if anyone can help with this problem: >> >> > >> >> > I am trying to open 16-bit tif files with the Python Imaging Library, >> >> > with >> >> > this code: >> >> > >> >> > im0 = Image.open (incolor) >> >> > >> >> > I get this error: >> >> > >> >> > Traceback (most recent call last): >> >> > File "find.frame.py", line 137, in <module> >> >> > im0 = Image.open (incolor) >> >> > File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 1917, in >> >> > open >> >> > raise IOError("cannot identify image file") >> >> > IOError: cannot identify image file >> >> > >> >> > My code works fine with 8bit tiffs. Attatched is an example image >> >> > file >> >> > that >> >> > it won't read in. >> >> > >> >> > Any help would be greatly appreciated >> >> > Dan >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > _______________________________________________ >> >> > Image-SIG maillist - image-...@python.org >> >> > http://mail.python.org/mailman/listinfo/image-sig >> >> > >> >> > >> > >> > > > _______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig