<div>I am doing some image processing on images. I use PIL to resize the images.</div><div><br></div><div>The image in question is a multilayered TIFF image. When I run it through my code, all I get is an image with a green background and no detail. It is as if the image is being corrupted, or not being read correctly by PIL.</div>
<div><br></div><div>I have got the repro case down to a few lines of python code.</div><div><br></div><div>--</div><div><div>import os</div><div>import sys</div><div>import Image</div><div>import ImageFile</div><div>import StringIO</div>
<div><br></div><div>data = None</div><div>with open(sys.argv[1]) as fp:</div><div>    data = fp.read()</div><div><br></div><div><br></div><div>img = Image.open(StringIO.StringIO(data))</div><div><br></div><div>print img.format, img.size, img.mode, img.getbands()</div>
<div>#img.show()</div><div><br></div><div>img1 = img.convert("RGB")</div><div>print img1.format, img1.size, img1.mode, img1.getbands()</div><div>#img1.show()</div><div><br></div><div>out = StringIO.StringIO()</div>
<div>img1.save (out, "JPEG" , quality=95)</div><div><br></div><div>with open(sys.argv[2], 'w') as f:</div><div>    f.write(out.getvalue())</div></div><div>--</div><div><br></div><div><div>At each step if you comment out the img.show() I get an image with a green background, and no detail</div>
<div><br></div><div><br></div><div>I pass in <inputfile> <outputfile> as arguments to this tool</div></div><div><br></div><div>Here is the source image URL: <a href="http://feroze.s3.amazonaws.com/ptiff_file.jpg">http://feroze.s3.amazonaws.com/ptiff_file.jpg</a></div>
<div><br></div><div>Any idea what I am doing wrong?</div><div><br></div><div>Thanks,</div><div><br></div><div>feroze.</div>