You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>>> from PIL import Image
>>> x = Image.open('sample.tiff')
>>> x.save('test.tiff')
_TIFFVSetField: test.tiff: Bad value 50048 for "SampleFormat" tag.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PIL/Image.py", line 1693, in save
save_handler(self, fp, filename)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PIL/TiffImagePlugin.py", line 1191, in _save
e = Image._getencoder(im.mode, 'libtiff', a, im.encoderconfig)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PIL/Image.py", line 434, in _getencoder
return encoder(mode, *args + extra)
RuntimeError: Error setting from dictionary
I'm seeing it come in with ExtraSamples=1, meaning RGBa (with premultiplied alpha), and it's trying to save as RGBA, or plain old alpha. Which makes some sense, because that's the approved mode for general usage in Pillow.
I'm not sure why it's throwing an error with ExtraSamples ==2, best guess is that it's sending an int and tiff is expecting a short. This may only fail with BigEndian tiffs.
{256: 57, 257: 54, 258: 8, 259: 5, 262: 2, 274: 1, 338: 2, 339: [1, 1, 1, 1], 277: 4, 284: 1, 317: 2}
_TIFFVSetField: out.tiff: Bad value 2 for "ExtraSamples" tag.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/PIL/Image.py", line 1694, in save
File "build/bdist.linux-x86_64/egg/PIL/TiffImagePlugin.py", line 1191, in _save
File "build/bdist.linux-x86_64/egg/PIL/Image.py", line 434, in _getencoder
RuntimeError: Error setting from dictionary
Thanks for that info. Starting with that, and looking at documentation, I see the line -
If SamplesPerPixel is, say, 5 then ExtraSamples will contain 2 values, one for each extra sample.
SamplesPerPixel is in fact, 4 for this image. However, I can't yet see how to specify 2 values.
I looked at the SampleFormat tag, which has the value - [1, 1, 1, 1] - thinking that would be a good example of multiple values. However, if you remove the SamplesPerPixel tag, the error becomes -
Bad value 21504 for "SampleFormat" tag.
where 21504 is a number that changes every time, I'm guessing the pointer being mistakenly read as the value. The documentation states that it should be 1-6.
I've come to the conclusion that yes, #1059 is solving this exact problem. However, what I find discouraging is that when I checkout that branch, it cannot identify this image file.
Failures to identify image files can usually be debugged by uncommenting the traceback.print_exc() lines in Image.py. Here, the #1059 TiffImagePlugin is correctly reading SampleFormat as (1, 1, 1, 1), but a new entry "just" needs to be created in OPEN_INFO. Can someone look into the correct value for mode and rawmode?
In fact, it it not clear to me what purpose does rawmode serve.
Activity
wiredfool commentedon May 11, 2015
There's something screwy going on with that one.
I'm seeing it come in with ExtraSamples=1, meaning RGBa (with premultiplied alpha), and it's trying to save as RGBA, or plain old alpha. Which makes some sense, because that's the approved mode for general usage in Pillow.
I'm not sure why it's throwing an error with ExtraSamples ==2, best guess is that it's sending an int and tiff is expecting a short. This may only fail with BigEndian tiffs.
So, I'm going to say related to #1059
radarhere commentedon Jun 10, 2015
Thanks for that info. Starting with that, and looking at documentation, I see the line -
SamplesPerPixel is in fact, 4 for this image. However, I can't yet see how to specify 2 values.
I looked at the SampleFormat tag, which has the value - [1, 1, 1, 1] - thinking that would be a good example of multiple values. However, if you remove the SamplesPerPixel tag, the error becomes -
where 21504 is a number that changes every time, I'm guessing the pointer being mistakenly read as the value. The documentation states that it should be 1-6.
I've come to the conclusion that yes, #1059 is solving this exact problem. However, what I find discouraging is that when I checkout that branch, it cannot identify this image file.
anntzer commentedon Jun 12, 2015
Failures to identify image files can usually be debugged by uncommenting the
traceback.print_exc()lines inImage.py. Here, the #1059 TiffImagePlugin is correctly reading SampleFormat as (1, 1, 1, 1), but a new entry "just" needs to be created in OPEN_INFO. Can someone look into the correct value formodeandrawmode?In fact, it it not clear to me what purpose does
rawmodeserve.anntzer commentedon Jun 12, 2015
OK, I guess
rawmodeis basically transformed into packing information inPack.candUnpack.c.Support too long ExtraSamples.
Support too long ExtraSamples.
Support too long ExtraSamples.
Support too long ExtraSamples.
Support too long ExtraSamples.
radarhere commentedon Sep 20, 2015
Resolved by #1419