相关疑难解决方法(0)

在JPG图像上操作时,"无法将模式P写为JPEG"

我正在尝试调整一些图像的大小,其中大部分都是JPG.但在一些图像中,我收到错误:

Traceback (most recent call last):
  File "image_operation_new.py", line 168, in modifyImage
    tempImage.save(finalName);
  File "/Users/kshitiz/.virtualenvs/django_project/lib/python2.7/site-     packages/PIL/Image.py", line 1465, in save
   save_handler(self, fp, filename)
  File "/Users/kshitiz/.virtualenvs/django_project/lib/python2.7/site-   packages/PIL/JpegImagePlugin.py", line 455, in _save
    raise IOError("cannot write mode %s as JPEG" % im.mode)
IOError: cannot write mode P as JPEG
Run Code Online (Sandbox Code Playgroud)

我没有改变图像类型,我正在使用枕头库.我的操作系统是Mac OS X.我该如何解决这个问题?

python macos python-imaging-library pillow

54
推荐指数
3
解决办法
3万
查看次数

不能将RGBA模式写为JPEG

我正在学习使用'枕头5.0'后面的书'用蟒蛇自动化无聊的东西'

有关图像对象的信息

In [79]: audacious = auda
In [80]: print(audacious.format, audacious.size, audacious.mode)
PNG (1094, 960) RGBA
Run Code Online (Sandbox Code Playgroud)

当我尝试转换文件类型时,它报告错误.

In [83]: audacious.save('audacious.jpg')
OSError: cannot write mode RGBA as JPEG
Run Code Online (Sandbox Code Playgroud)

书中没有这样的错误.

pillow python-3.6

19
推荐指数
1
解决办法
2万
查看次数