ValueError: too many values to unpack
18.104.22.168. tRNS Transparency (PNG Specification)
Can you post the code that you're using to drive this? It looks like your exception is in save, not open. Either way, it opens and saves ok for me.
>>> from PIL import Image
>>> im = Image.open('e2a6f2ea-88f3-11e3-9d40-b86f41857491.png')
Yes, I'm sorry, I made a mistake in the description.
Ah, so you're converting to an RGB: image = image.convert('RGB') which makes the tRNS chunk incorrect.
image = image.convert('RGB')
Unfortunately, there's less information in the tRNS chunk in rgb mode -- in P mode it's a vector of alpha values, in RGB it's a single color, so that conversion (if done) would be a lossy conversion.
For this image, since there's no transparent pixels, you can get it to save by setting im.info['transparency'] to none after the conversion.
In general though, this is a bug in Image.py:convert() where mode P with transparency images are promoted to RGB. There's also going to be a similar issue with mode L images, and a different, but related issue promoting P to RGBA.
P-> RGBA is handled correctly in the guts of the ordinary p conversions, as (somewhere) the palette that's in ImagePalette is converted into an RGBA palette and from there, is all well and good.
So, there's a need for conversion of the transparency between P/RGB/L, but not RGBA. I'm not sure if there's currently an easy way to get the color for a palette entry. There probably should be. Additionally, I've seen at least a couple of different organizations of the palette data in ImagePalette.py.
Can we get a fix for this in 2.4.0?
Yeah, I think it can happen.
Tests for #510
Transparency conversion for L, RGP and P images, fixes #510