Pillow bug?

Ian Kelly ian.g.kelly at gmail.com
Tue Mar 24 16:14:18 EDT 2015


On Tue, Mar 24, 2015 at 1:52 PM,  <kai.peters at gmail.com> wrote:
> Judging from the message archive, the image-sig list is (just about) dead?
>
> Disclaimer: Am a newbie - so anything is possible
>
>
> using 'RGB' works fine
>
>     img = Image.new('RGB', (inktile[0], inktile[1]), bgcolor)
>
> using '1' or 'L' does not (see trace below)
>
>     img = Image.new('L', (inktile[0], inktile[1]), bgcolor)
>
>
> I change nothing else but the first parameter. If I switch the 'L' back to 'RGB' it works again.
>
>
>     img      = Image.new('L', (inktile[0], inktile[1]), bgcolor)
>   File "C:\Python27\lib\site-packages\PIL\Image.py", line 2015, in new
>     return Image()._new(core.fill(mode, size, color))
> TypeError: an integer is required
>
> The docs say that '1' and 'L' are supported - something broken? Something I do not understand?

What is the value of bgcolor that you're passing in? Per the docs: "If
given, this should be a single integer or floating point value for
single-band modes, and a tuple for multi-band modes (one value per
band)." So if you're changing from a multi-band mode to a single-band
mode, you would need to change the color argument as well.



More information about the Python-list mailing list