Document missing attributes

This commit is contained in:
Andrew Murray 2020-07-23 22:40:02 +10:00
parent 696aac95cb
commit 836dcc5ba0
4 changed files with 23 additions and 16 deletions

View File

@ -114,12 +114,7 @@ nitpicky = True
# generating warnings in “nitpicky mode”. Note that type should include the domain name
# if present. Example entries would be ('py:func', 'int') or
# ('envvar', 'LD_LIBRARY_PATH').
nitpick_ignore = [
("py:attr", "PIL.Image.Image.tag"),
("py:attr", "PIL.Image.Image.tag_v2"),
("py:attr", "PIL.Image.Image.tile"),
("py:attr", "PIL.TiffImagePlugin.ImageFileDirectory_v2.tagtype"),
]
# nitpick_ignore = []
# -- Options for HTML output ----------------------------------------------

View File

@ -186,7 +186,7 @@ Reading local images
The GIF loader creates an image memory the same size as the GIF files *logical
screen size*, and pastes the actual pixel data (the *local image*) into this
image. If you only want the actual pixel rectangle, you can manipulate the
:py:attr:`~PIL.Image.Image.size` and :py:attr:`~PIL.Image.Image.tile`
:py:attr:`~PIL.Image.Image.size` and :py:attr:`~PIL.ImageFile.ImageFile.tile`
attributes before loading the file::
im = Image.open(...)
@ -764,8 +764,8 @@ The :py:meth:`~PIL.Image.open` method sets the following
**dpi**
Image resolution as an ``(xdpi, ydpi)`` tuple, where applicable. You can use
the :py:attr:`~PIL.Image.Image.tag` attribute to get more detailed
information about the image resolution.
the :py:attr:`~PIL.TiffImagePlugin.TiffImageFile.tag` attribute to get more
detailed information about the image resolution.
.. versionadded:: 1.1.5
@ -776,8 +776,8 @@ The :py:meth:`~PIL.Image.open` method sets the following
.. versionadded:: 1.1.5
The :py:attr:`~PIL.Image.Image.tag_v2` attribute contains a dictionary
of TIFF metadata. The keys are numerical indexes from
The :py:attr:`~PIL.TiffImagePlugin.TiffImageFile.tag_v2` attribute contains a
dictionary of TIFF metadata. The keys are numerical indexes from
:py:data:`.TiffTags.TAGS_V2`. Values are strings or numbers for single
items, multiple values are returned in a tuple of values. Rational
numbers are returned as a :py:class:`~PIL.TiffImagePlugin.IFDRational`
@ -786,8 +786,8 @@ object.
.. versionadded:: 3.0.0
For compatibility with legacy code, the
:py:attr:`~PIL.Image.Image.tag` attribute contains a dictionary of
decoded TIFF fields as returned prior to version 3.0.0. Values are
:py:attr:`~PIL.TiffImagePlugin.TiffImageFile.tag` attribute contains a dictionary
of decoded TIFF fields as returned prior to version 3.0.0. Values are
returned as either strings or tuples of numeric values. Rational
numbers are returned as a tuple of ``(numerator, denominator)``.

View File

@ -95,6 +95,8 @@ class ImageFile(Image.Image):
self.custom_mimetype = None
self.tile = None
""" A list of tile descriptors, or ``None`` """
self.readonly = 1 # until we know better
self.decoderconfig = ()

View File

@ -472,6 +472,8 @@ class ImageFileDirectory_v2(MutableMapping):
self._endian = "<"
else:
raise SyntaxError("not a TIFF IFD")
self.tagtype = {}
""" Dictionary of tag types """
self.reset()
(self.next,) = self._unpack("L", ifh[4:])
self._legacy_api = False
@ -972,17 +974,25 @@ class TiffImageFile(ImageFile.ImageFile):
format_description = "Adobe TIFF"
_close_exclusive_fp_after_loading = False
def __init__(self, fp=None, filename=None):
self.tag_v2 = None
""" Image file directory (tag dictionary) """
self.tag = None
""" Legacy tag entries """
super().__init__(fp, filename)
def _open(self):
"""Open the first image in a TIFF file"""
# Header
ifh = self.fp.read(8)
# image file directory (tag dictionary)
self.tag_v2 = ImageFileDirectory_v2(ifh)
# legacy tag/ifd entries will be filled in later
self.tag = self.ifd = None
# legacy ifd entries will be filled in later
self.ifd = None
# setup frame pointers
self.__first = self.__next = self.tag_v2.next