mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
Merge pull request #4811 from radarhere/attributes
This commit is contained in:
commit
e5415ca082
|
@ -114,12 +114,7 @@ nitpicky = True
|
||||||
# generating warnings in “nitpicky mode”. Note that type should include the domain name
|
# generating warnings in “nitpicky mode”. Note that type should include the domain name
|
||||||
# if present. Example entries would be ('py:func', 'int') or
|
# if present. Example entries would be ('py:func', 'int') or
|
||||||
# ('envvar', 'LD_LIBRARY_PATH').
|
# ('envvar', 'LD_LIBRARY_PATH').
|
||||||
nitpick_ignore = [
|
# 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"),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for HTML output ----------------------------------------------
|
# -- Options for HTML output ----------------------------------------------
|
||||||
|
|
|
@ -186,7 +186,7 @@ Reading local images
|
||||||
The GIF loader creates an image memory the same size as the GIF file’s *logical
|
The GIF loader creates an image memory the same size as the GIF file’s *logical
|
||||||
screen size*, and pastes the actual pixel data (the *local image*) into this
|
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
|
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::
|
attributes before loading the file::
|
||||||
|
|
||||||
im = Image.open(...)
|
im = Image.open(...)
|
||||||
|
@ -764,8 +764,8 @@ The :py:meth:`~PIL.Image.open` method sets the following
|
||||||
|
|
||||||
**dpi**
|
**dpi**
|
||||||
Image resolution as an ``(xdpi, ydpi)`` tuple, where applicable. You can use
|
Image resolution as an ``(xdpi, ydpi)`` tuple, where applicable. You can use
|
||||||
the :py:attr:`~PIL.Image.Image.tag` attribute to get more detailed
|
the :py:attr:`~PIL.TiffImagePlugin.TiffImageFile.tag` attribute to get more
|
||||||
information about the image resolution.
|
detailed information about the image resolution.
|
||||||
|
|
||||||
.. versionadded:: 1.1.5
|
.. versionadded:: 1.1.5
|
||||||
|
|
||||||
|
@ -776,8 +776,8 @@ The :py:meth:`~PIL.Image.open` method sets the following
|
||||||
.. versionadded:: 1.1.5
|
.. versionadded:: 1.1.5
|
||||||
|
|
||||||
|
|
||||||
The :py:attr:`~PIL.Image.Image.tag_v2` attribute contains a dictionary
|
The :py:attr:`~PIL.TiffImagePlugin.TiffImageFile.tag_v2` attribute contains a
|
||||||
of TIFF metadata. The keys are numerical indexes from
|
dictionary of TIFF metadata. The keys are numerical indexes from
|
||||||
:py:data:`.TiffTags.TAGS_V2`. Values are strings or numbers for single
|
:py:data:`.TiffTags.TAGS_V2`. Values are strings or numbers for single
|
||||||
items, multiple values are returned in a tuple of values. Rational
|
items, multiple values are returned in a tuple of values. Rational
|
||||||
numbers are returned as a :py:class:`~PIL.TiffImagePlugin.IFDRational`
|
numbers are returned as a :py:class:`~PIL.TiffImagePlugin.IFDRational`
|
||||||
|
@ -786,8 +786,8 @@ object.
|
||||||
.. versionadded:: 3.0.0
|
.. versionadded:: 3.0.0
|
||||||
|
|
||||||
For compatibility with legacy code, the
|
For compatibility with legacy code, the
|
||||||
:py:attr:`~PIL.Image.Image.tag` attribute contains a dictionary of
|
:py:attr:`~PIL.TiffImagePlugin.TiffImageFile.tag` attribute contains a dictionary
|
||||||
decoded TIFF fields as returned prior to version 3.0.0. Values are
|
of decoded TIFF fields as returned prior to version 3.0.0. Values are
|
||||||
returned as either strings or tuples of numeric values. Rational
|
returned as either strings or tuples of numeric values. Rational
|
||||||
numbers are returned as a tuple of ``(numerator, denominator)``.
|
numbers are returned as a tuple of ``(numerator, denominator)``.
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,8 @@ class ImageFile(Image.Image):
|
||||||
self.custom_mimetype = None
|
self.custom_mimetype = None
|
||||||
|
|
||||||
self.tile = None
|
self.tile = None
|
||||||
|
""" A list of tile descriptors, or ``None`` """
|
||||||
|
|
||||||
self.readonly = 1 # until we know better
|
self.readonly = 1 # until we know better
|
||||||
|
|
||||||
self.decoderconfig = ()
|
self.decoderconfig = ()
|
||||||
|
|
|
@ -472,6 +472,8 @@ class ImageFileDirectory_v2(MutableMapping):
|
||||||
self._endian = "<"
|
self._endian = "<"
|
||||||
else:
|
else:
|
||||||
raise SyntaxError("not a TIFF IFD")
|
raise SyntaxError("not a TIFF IFD")
|
||||||
|
self.tagtype = {}
|
||||||
|
""" Dictionary of tag types """
|
||||||
self.reset()
|
self.reset()
|
||||||
(self.next,) = self._unpack("L", ifh[4:])
|
(self.next,) = self._unpack("L", ifh[4:])
|
||||||
self._legacy_api = False
|
self._legacy_api = False
|
||||||
|
@ -972,17 +974,25 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
format_description = "Adobe TIFF"
|
format_description = "Adobe TIFF"
|
||||||
_close_exclusive_fp_after_loading = False
|
_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):
|
def _open(self):
|
||||||
"""Open the first image in a TIFF file"""
|
"""Open the first image in a TIFF file"""
|
||||||
|
|
||||||
# Header
|
# Header
|
||||||
ifh = self.fp.read(8)
|
ifh = self.fp.read(8)
|
||||||
|
|
||||||
# image file directory (tag dictionary)
|
|
||||||
self.tag_v2 = ImageFileDirectory_v2(ifh)
|
self.tag_v2 = ImageFileDirectory_v2(ifh)
|
||||||
|
|
||||||
# legacy tag/ifd entries will be filled in later
|
# legacy IFD entries will be filled in later
|
||||||
self.tag = self.ifd = None
|
self.ifd = None
|
||||||
|
|
||||||
# setup frame pointers
|
# setup frame pointers
|
||||||
self.__first = self.__next = self.tag_v2.next
|
self.__first = self.__next = self.tag_v2.next
|
||||||
|
|
Loading…
Reference in New Issue
Block a user