使用PIL/pi将tiff(I;16)转换为JPG

2024-04-25 08:04:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我在将tiff图像从显微镜转换为jpeg(应该在web应用程序中显示)时遇到问题。 我尝试了以下方法:

image = Image.open(file_name)
image.convert(mode="RGB")
image.save('my.jpeg')

>>IOError: cannot write mode I;16 as JPEG

任何人都有将16位TIFF文件转换为JPEG格式的经验。。。 我在下面链接了这样一个文件。 谢谢你的帮助!

https://drive.google.com/open?id=0B04N02JqhWJOWjBPY1RRZkIwbTg


Tags: 文件方法name图像imageweb应用程序convert
1条回答
网友
1楼 · 发布于 2024-04-25 08:04:17

它要么是虫子,要么是没有在枕头上留下痕迹。以下是解决方法:

import Image
image = Image.open("Fredy1_002.tif")
image.mode = 'I'
image.point(lambda i:i*(1./256)).convert('L').save('my.jpeg')

相关问题 更多 >