OSError: cannot write mode P as JPEG

简介: OSError: cannot write mode P as JPEG

对于这个问题,需要做的也很简单,无非就是将模式“P”转化为“RGB”模式,再保存为“jpg”就可以了,所以只用增加两行代码:

   if img.mode == "P":

       img = img.convert('RGB')

目录
相关文章
|
8月前
|
XML 移动开发 Unix
open(file, mode=‘r‘, buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=No
open(file, mode=‘r‘, buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=No
|
10月前
报错:cannot read poperties of undefined(reading ‘then‘)
报错:cannot read poperties of undefined(reading ‘then‘)
|
网络协议
av_interleaved_write_frame -32 broken pipe
av_interleaved_write_frame -32 broken pipe
341 0
av_interleaved_write_frame -32 broken pipe
|
编解码
av_read_frame返回值为-5 Input/output error
av_read_frame返回值为-5 Input/output error
211 0
运用MyQR模块生成图片二维码报错:OSError: cannot write mode RGBA as JPEG
运用MyQR模块生成图片二维码报错:OSError: cannot write mode RGBA as JPEG
运用MyQR模块生成图片二维码报错:OSError: cannot write mode RGBA as JPEG
UE Operation File [ Read / Write ] DTOperateFile 插件说明
UE Operation File [ Read / Write ] DTOperateFile 插件说明
116 0
|
Windows
UE INI File Operation [ Read / Write ] Plug-in description
UE INI File Operation [ Read / Write ] Plug-in description
92 0
base64转图片的时候Can't read input file!
如果不去掉编码中的图片头信息,就会报Can't read input file!。 一开始还以为是文件路径格式有问题,然后看了看我之前用的,就有一个区别就是没有去头信息。
Can‘t read file : End of file found 文件:txn_current、current svn无法正常读取文件
Can‘t read file : End of file found 文件:txn_current、current svn无法正常读取文件
Can‘t read file : End of file found 文件:txn_current、current svn无法正常读取文件
OSError: image file is truncated (12 bytes not processed) Premature end of JPEG file
OSError: image file is truncated (12 bytes not processed) Premature end of JPEG file
558 0