Can anyone tell me why does this problem occur?

On Apr 12, 2:13 pm, higer <higerinbeij...@gmail.com> wrote:
> Thanks for your suggestion. But Python 2.5 already has zlib moudle.
> To png file,I wrote lines of code to save it first on disk and then
> handled the saved copy,then that works.
> I do not why there is some differencies between png file and file of
> other formats.The following is my code:
>
>                 parser = ImageFile.Parser()
>                 for chunk in f.chunks():
>                     parser.feed(chunk)
>                 img = parser.close()
>
>                 if format == 'png':
>                     des_origin_f = open("tmp.png","ab")
>                     for chunk in f.chunks():
>                         des_origin_f.write(chunk)
>                     des_origin_f.close()
>                     img = Image.open("tmp.png")
>
>                 ##other operations to handle the image
>                 img.save("test"+"."+fileExt) #save this image
>
> I can not make sure whether the problem is caused by Django. Because
> what my code tells is thatPILcan handle the png file from a disk,but
> can not handle a png file from a Django response(you can see my code
> in the first message and compare with the code above).
>
> On Apr 10, 9:46 pm, Brian Neal <bgn...@gmail.com> wrote:
>
> > On Apr 9, 12:45 am, higer <higerinbeij...@gmail.com> wrote:
>
> > > When I upload a PNG file and usePILto handle it,there will be an
> > > error occured:
> > > 'NoneType' object is unsubscriptable
>
> > > I do not know why and other formats(BMP GIF JPG JPEG) are all ok.
>
> > I don't know if this is your problem, but in order to use certain file
> > formats inPILyou have to have some prequisites installed. Here is
> > thePILdoc page for PNG support:
>
> >http://www.pythonware.com/library/pil/handbook/format-png.htm
>
> > In particular, note:
>
> > "PILidentifies, reads, and writes PNG files containing "1", "L", "P",
> > "RGB", or "RGBA" data. Interlaced files are currently not supported."
>
> > And also:
>
> > "Note: To enable PNG support, you need to build and install the ZLIB
> > compression library before building the Python Imaging Library. See
> > the distribution README for details."
>
> > BN
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to