Pieter-Jan Briers
Pieter-Jan Briers

Reputation: 158

Pillow PixelAccess TypeError: function takes exactly 1 argument (4 given)

I'm trying to loop over some pixels and edit them with PixelAccess. For some reason, when I try to set the pixels, Python gives me TypeError: function takes exactly 1 argument (4 given)

pixels[(x, y)] = pix

is the exact code.

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 is a 4-tuple of numbers for the RGBA values of the image. I tried to change the amount of numbers of items in the tuple by adding some zeroes, and the count given in the error does go up.

Upvotes: 2

Views: 1187

Answers (1)

Pieter-Jan Briers
Pieter-Jan Briers

Reputation: 158

Figured it out, the image was on mode P so I had to convert it to RGBA beforehand.

Upvotes: 5

Related Questions