使用PIL/枕头将tiff(I; 16)转换为JPG [英] Convert tiff (I;16) to JPG with PIL/pillow

查看:340
本文介绍了使用PIL/枕头将tiff(I; 16)转换为JPG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将tiff图像从显微镜转换为jpeg时出现问题,应该在网络应用程序中显示该图像. 我尝试了以下方法:

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

任何人都具有将16位TIFF文件转换为jpegs的经验. 我已经在下面链接了这样的文件. 感谢您的帮助!

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

推荐答案

它是错误或在PIL/Pillow中未实现.这是一种解决方法:

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')

这篇关于使用PIL/枕头将tiff(I; 16)转换为JPG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆