问题
I have a problem converting a tiff image from a microscope to a jpeg, which should be shown within a web application. I tried the following:
image = Image.open(file_name)
image.convert(mode="RGB")
image.save('my.jpeg')
>>IOError: cannot write mode I;16 as JPEG
Anybody has some experience in converting 16-bit TIFF files to jpegs... I have linked such a file below. Thanks for your help!
https://drive.google.com/open?id=0B04N02JqhWJOWjBPY1RRZkIwbTg
回答1:
It's either a bug or unimplemented in PIL/Pillow. Here is a workaround:
import Image
image = Image.open("Fredy1_002.tif")
image.mode = 'I'
image.point(lambda i:i*(1./256)).convert('L').save('my.jpeg')
来源:https://stackoverflow.com/questions/43978819/convert-tiff-i16-to-jpg-with-pil-pillow