python - 枕头 PixelAccess 类型错误 : function takes exactly 1 argument (4 given)

标签 python image python-imaging-library

我正在尝试循环某些像素并使用 PixelAccess 对其进行编辑。由于某种原因,当我尝试设置像素时,Python 给出了 TypeError: function gets正好 1 个参数(给定 4 个)

pixels[(x, y)] = pix

是确切的代码。

Traceback (most recent call last):
  File "./gen_shuttletiles.py", line 86, in <module>
    main()
  File "./gen_shuttletiles.py", line 76, in main
    pixels[(x, y)] = pix
TypeError: function takes exactly 1 argument (4 given)

pix 是图像 RGBA 值的 4 元组数字。 我尝试通过添加一些零来更改元组中项目的数量,并且错误中给出的计数确实增加了。

最佳答案

我发现,图像处于 P 模式,因此我必须事先将其转换为 RGBA

关于python - 枕头 PixelAccess 类型错误 : function takes exactly 1 argument (4 given),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43528019/

相关文章:

python - 在 GitHub Actions 中发布缓存 python 依赖项

python / Pandas : Drop rows from data frame on string match from list

html - div 中的图像在图像下方有额外的空间

python - 在不缩放的情况下改进图像的 OCR(使用 PIL、pixbuf)?

python - 当我在其上叠加另一个图像时,PIL 会弄脏图像

python - Pandas:在组中将值向下移动一行

python - 对 Python 脚本进行 deamonizing 后无法读取外部命令的 stdout 输出

c# - 将图像作为二进制数据存储在数据库中

html - 水平显示无序列表

python - PIL open() 方法不适用于 BytesIO