PIL can't read binary
Chris Angelico
rosuav at gmail.com
Tue Sep 23 04:36:09 EDT 2014
On Tue, Sep 23, 2014 at 6:29 PM, Frank Liou <fk26541598fk at gmail.com> wrote:
> I use PIL Image.open()
>
> but it show 'list' object has no attribute 'open'
>
> this is my code
>
> class Image2():
> trans = connection.begin()
> session = Session()
> ProductId = session.query(ProductEntity.ProductId).filter(ProductEntity.CompanyId=="2").all()
> Image = session.query(ProductImageGalleryEntity).filter(ProductImageGalleryEntity.ProductId=="20").all()
> PicFromDataBase = Image[0].ProductImage
> try:
> b = Image.open(str(PicFromDataBase))
> except Exception as e:
> sad = e
I suspect a lot of this ought to be in a method, probably __init__,
rather than raw in the class definition. However, the problem here is
that your Image is a list (as indicated by the exception), and you
probably want to open just one of its elements - maybe
Image[0].open(...). You may also want to iterate over the entire list,
which would cope better with the possibility of having none or
multiple.
ChrisA
More information about the Python-list
mailing list