# The PIL.ImageFile Module

_ParserFile(data) (class) [#]

  (Internal) Support class for the Parser file.

  For more information about this class, see The _ParserFile Class.

_safe_read(fp, size) [#]

  Reads large blocks in a safe way. Unlike fp.read(n), this function doesn't trust the user. If the requested size is larger than SAFEBLOCK, the file is read block by block.

  fp
    File handle. Must implement a read method.
  size
    Number of bytes to read.
  Returns:
    A string containing up to size bytes of data.
_save(im, fp, tile) [#]

  (Helper) Save image body to file.

  im
    Image object.
  fp
    File object.
  tile
    Tile list.
ImageFile(fp=None, filename=None) (class) [#]

  Base class for image file handlers.

  For more information about this class, see The ImageFile Class.

Parser (class) [#]

  Incremental image parser.

  For more information about this class, see The Parser Class.

StubImageFile (class) [#]

  Base class for stub image loaders.

  For more information about this class, see The StubImageFile Class.

## The _ParserFile Class

_ParserFile(data) (class) [#]

  (Internal) Support class for the Parser file.

## The ImageFile Class

ImageFile(fp=None, filename=None) (class) [#]

  Base class for image file handlers.

## The Parser Class

Parser (class) [#]

  Incremental image parser. This class implements the standard feed/close consumer interface.

close() [#]

  (Consumer) Close the stream.

  Returns:
    An image object.
  Raises IOError:
    If the parser failed to parse the image file.
feed(data) [#]

  (Consumer) Feed data to the parser.

  data
    A string buffer.
  Raises IOError:
    If the parser failed to parse the image file.
reset() [#]

  (Consumer) Reset the parser. Note that you can only call this method immediately after you've created a parser; parser instances cannot be reused.

## The StubImageFile Class

StubImageFile (class) [#]

  Base class for stub image loaders.

  A stub loader is an image loader that can identify files of a certain format, but relies on external code to load the file.

_load() [#]

  (Hook) Find actual image loader.