当使用pythons在构建函数“打开”时,我收到了一个错误,并且不知道如何使它对png文件工作。
:img =open('here.png').read()
错误:UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 101: character maps to <undefined>
发布于 2018-05-10 01:45:29
要打开图像,我建议您使用python的opencv
或PIL
模块。
使用 OpenCV
import cv2
img = cv2.imread('here.png',0)
使用PIL的
from PIL import Image
im = Image.open("here.png")
im.show()
如果您只想使用open
打开
img =open('here.png','rb').read()
发布于 2018-05-10 01:58:31
如果您试图通过FTP发送图像文件,则可能需要打开该文件,请使用以下命令
file = open(file_location,'rb')
然后你可以用它来发送文件
ftp.storbinary('STOR '+file_location, file)
我每天使用它一百万次:)
发布于 2018-05-10 01:54:13
我正在为python3使用imageio,它调用了PIL的一个分支--枕头包。
frame = imageio.imread('png here')
为了确保框架没有被转换成像uint16 => uint8这样的东西,我确定了dtype。
print (frame.dtype)
https://stackoverflow.com/questions/50264277
复制相似问题