简体   繁体   English

如何在 python 中将 jpeg 转换为 tiff 文件

[英]how to convert jpeg to tiff file in python

Is there any way to convert.jpeg to.tiff file?有没有办法将.jpeg 转换为.tiff 文件?

If yes, then how to do that?如果是,那么该怎么做?

There are many library in Python that can convert file from one format to another. Python 中有许多库可以将文件从一种格式转换为另一种格式。

But, I have not found anything for this problem.但是,我还没有找到任何解决这个问题的方法。

Thanks in advance!提前致谢!

see this 看到这个

from PIL import Image
im = Image.open('yourImg.jpg')
im.save("pathToSave/hello.tiff", 'TIFF')

You can use PIL (Python Imaging Library) for this:您可以为此使用PIL(Python 图像库)

import Image
im = Image.open('test.jpg')
im.save('test.tiff')  # or 'test.tif'

Also, this was the first result for your problem on Google, make sure you google extensively first.此外,这是您在 Google 上遇到的问题的第一个结果,请确保您首先广泛使用 Google。

According to OpenCV docs for functions used for image and video reading and writing imread does support JPEG files and imwrite can save TIFF files, though with some limitations:根据OpenCV 文档,用于图像和视频读写的函数imread确实支持 JPEG 文件,而imwrite可以保存 TIFF 文件,但有一些限制:

Only 8-bit (or 16-bit unsigned (CV_16U) in case of PNG, JPEG 2000, and TIFF) single-channel or 3-channel (with 'BGR' channel order) images can be saved using this function.使用此 function 只能保存 8 位(或 16 位无符号 (CV_16U),对于 PNG、JPEG 2000 和 TIFF)单通道或 3 通道(具有“BGR”通道顺序)图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM