![]() | ||||||
![]() | ![]() |
The ImageFile ModuleThis module provides support functions for the image open and save functions. In addition, it provides a Parser class which you can use to decode an image piece by piece, for example while receiving it over a network connection. This class implements the same consumer interface as the standard sgmllib and xmllib modules. ExampleExample: Parse An Image import ImageFile fp = open("lena.pgm", "rb") p = ImageFile.Parser() while 1: s = fp.read(1024) if not s: break p.feed(s) im = p.close() im.save("copy.jpg") FunctionsParser (constructor)Parser(). Creates a parser object. Parsers cannot be reused. Methodsfeedfeed(data). Feed a string of data to the parser. This method may raise an IOError exception. closeclose(). Tells the parser to finish decoding. If the parser managed to decode an image, it returns an Image object. Otherwise, this method raises an IOError exception. Note: | ![]() |
![]() | ||
|
| |||||
![]() |
(this site looks better in browsers with stylesheet support. sorry!)