Pillow bug?

kai.peters at gmail.com kai.peters at gmail.com
Tue Mar 24 16:24:06 EDT 2015


On Tuesday, 24 March 2015 13:15:42 UTC-7, Ian  wrote:
> On Tue, Mar 24, 2015 at 1:52 PM,  Kai 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.

Good catch - that was it.

Thanks much!



More information about the Python-list mailing list