[Image-SIG] PngImagePlugin 0.5 fails to load Png files

Fredrik Lundh fredrik@pythonware.com
Mon, 16 Apr 2001 16:46:08 +0200


duncan wrote:

> There seems to be a problem with PngImagePlugin version 0.5 and 
> many but not all Png files (I was working my way through the 
> images in the Zope Book, and the mono ones load but the colour 
> ones don't). The problem is that version 0.5 has sprouted a line:
>         self.png.close()
> at line 269 near the end of PngImageFile._open.

here's the "official" patch for this bug (bug id @PIL21)

Cheers /F

*** \py20\PIL\pngimageplugin.py Thu Feb 08 21:40:41 2001
--- PIL/PngImagePlugin.py Mon Apr 16 14:13:29 2001
***************
*** 266,273 ****
              rawmode, data = self.png.im_palette
              self.palette = ImagePalette.raw(rawmode, data)
  
-         self.png.close()
- 
          self.__idat = len # used by load_read()
  
  
--- 267,272 ----
***************
*** 284,290 ****
  
  
      def load_read(self, bytes):
!         "Read more data from chunks (used by ImageFile.load)"
  
          while self.__idat == 0:
              # end of chunk, skip forward to next one
--- 283,289 ----
  
  
      def load_read(self, bytes):
!         "internal: read more image data"
  
          while self.__idat == 0:
              # end of chunk, skip forward to next one
***************
*** 309,315 ****
  
          return self.fp.read(bytes)
  
! #
  # --------------------------------------------------------------------
  # PNG writer
  
--- 308,321 ----
  
          return self.fp.read(bytes)
  
! 
!     def load_end(self):
!         "internal: finished reading image data"
! 
!         self.png.close()
!         self.png = None
! 
! 
  # --------------------------------------------------------------------
  # PNG writer