@@ -26,14 +26,14 @@ Pillow decodes files in two stages:
2626 it.
2727
2828An image plugin should contain a format handler derived from the
29- :py:class: `PIL.ImageFile.ImageFile ` base class. This class should
30- provide an ``_open `` method, which reads the file header and
31- sets up at least the :py:attr: `~PIL.Image.Image.mode ` and
32- :py:attr: `~PIL.Image.Image.size ` attributes . To be able to load the
33- file, the method must also create a list of ``tile `` descriptors,
34- which contain a decoder name, extents of the tile, and
35- any decoder-specific data. The format handler class must be explicitly
36- registered, via a call to the :py:mod: `~PIL.Image ` module.
29+ :py:class: `PIL.ImageFile.ImageFile ` base class. This class should provide an
30+ ``_open `` method, which reads the file header and set at least the internal
31+ ` _size ` and ` _mode ` attributes so that :py:attr: `~PIL.Image.Image.mode ` and
32+ :py:attr: `~PIL.Image.Image.size ` are populated . To be able to load the file,
33+ the method must also create a list of ``tile `` descriptors, which contain a
34+ decoder name, extents of the tile, and any decoder-specific data. The format
35+ handler class must be explicitly registered, via a call to the
36+ :py:mod: `~PIL.Image ` module.
3737
3838.. note :: For performance reasons, it is important that the
3939 ``_open `` method quickly rejects files that do not have the
@@ -96,13 +96,13 @@ true color.
9696 )
9797
9898
99- The format handler must always set the
100- :py:attr: ` ~PIL.Image.Image.size ` and :py:attr: `~PIL.Image.Image.mode `
101- attributes. If these are not set, the file cannot be opened. To
102- simplify the plugin, the calling code considers exceptions like
99+ The format handler must always populate the :py:attr: ` ~PIL.Image.Image.size `
100+ and :py:attr: `~PIL.Image.Image.mode ` attributes, by setting the internal
101+ ` _size ` and ` _mode ` attributes. If these are not set, the file cannot be
102+ opened. To simplify the plugin, the calling code considers exceptions like
103103:py:exc: `SyntaxError `, :py:exc: `KeyError `, :py:exc: `IndexError `,
104- :py:exc: `EOFError ` and :py:exc: `struct.error ` as a failure to identify
105- the file.
104+ :py:exc: `EOFError ` and :py:exc: `struct.error ` as a failure to identify the
105+ file.
106106
107107Note that the image plugin must be explicitly registered using
108108:py:func: `PIL.Image.register_open `. Although not required, it is also a good
0 commit comments