__init__.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. """Pillow (Fork of the Python Imaging Library)
  2. Pillow is the friendly PIL fork by Alex Clark and Contributors.
  3. https://github.com/python-pillow/Pillow/
  4. Pillow is forked from PIL 1.1.7.
  5. PIL is the Python Imaging Library by Fredrik Lundh and Contributors.
  6. Copyright (c) 1999 by Secret Labs AB.
  7. Use PIL.__version__ for this Pillow version.
  8. ;-)
  9. """
  10. import sys
  11. import warnings
  12. from . import _version
  13. # VERSION was removed in Pillow 6.0.0.
  14. __version__ = _version.__version__
  15. # PILLOW_VERSION is deprecated and will be removed in a future release.
  16. # Use __version__ instead.
  17. def _raise_version_warning():
  18. warnings.warn(
  19. "PILLOW_VERSION is deprecated and will be removed in Pillow 9 (2022-01-02). "
  20. "Use __version__ instead.",
  21. DeprecationWarning,
  22. stacklevel=3,
  23. )
  24. if sys.version_info >= (3, 7):
  25. def __getattr__(name):
  26. if name == "PILLOW_VERSION":
  27. _raise_version_warning()
  28. return __version__
  29. raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
  30. else:
  31. class _Deprecated_Version(str):
  32. def __str__(self):
  33. _raise_version_warning()
  34. return super().__str__()
  35. def __getitem__(self, key):
  36. _raise_version_warning()
  37. return super().__getitem__(key)
  38. def __eq__(self, other):
  39. _raise_version_warning()
  40. return super().__eq__(other)
  41. def __ne__(self, other):
  42. _raise_version_warning()
  43. return super().__ne__(other)
  44. def __gt__(self, other):
  45. _raise_version_warning()
  46. return super().__gt__(other)
  47. def __lt__(self, other):
  48. _raise_version_warning()
  49. return super().__lt__(other)
  50. def __ge__(self, other):
  51. _raise_version_warning()
  52. return super().__gt__(other)
  53. def __le__(self, other):
  54. _raise_version_warning()
  55. return super().__lt__(other)
  56. PILLOW_VERSION = _Deprecated_Version(__version__)
  57. del _version
  58. _plugins = [
  59. "BlpImagePlugin",
  60. "BmpImagePlugin",
  61. "BufrStubImagePlugin",
  62. "CurImagePlugin",
  63. "DcxImagePlugin",
  64. "DdsImagePlugin",
  65. "EpsImagePlugin",
  66. "FitsStubImagePlugin",
  67. "FliImagePlugin",
  68. "FpxImagePlugin",
  69. "FtexImagePlugin",
  70. "GbrImagePlugin",
  71. "GifImagePlugin",
  72. "GribStubImagePlugin",
  73. "Hdf5StubImagePlugin",
  74. "IcnsImagePlugin",
  75. "IcoImagePlugin",
  76. "ImImagePlugin",
  77. "ImtImagePlugin",
  78. "IptcImagePlugin",
  79. "JpegImagePlugin",
  80. "Jpeg2KImagePlugin",
  81. "McIdasImagePlugin",
  82. "MicImagePlugin",
  83. "MpegImagePlugin",
  84. "MpoImagePlugin",
  85. "MspImagePlugin",
  86. "PalmImagePlugin",
  87. "PcdImagePlugin",
  88. "PcxImagePlugin",
  89. "PdfImagePlugin",
  90. "PixarImagePlugin",
  91. "PngImagePlugin",
  92. "PpmImagePlugin",
  93. "PsdImagePlugin",
  94. "SgiImagePlugin",
  95. "SpiderImagePlugin",
  96. "SunImagePlugin",
  97. "TgaImagePlugin",
  98. "TiffImagePlugin",
  99. "WebPImagePlugin",
  100. "WmfImagePlugin",
  101. "XbmImagePlugin",
  102. "XpmImagePlugin",
  103. "XVThumbImagePlugin",
  104. ]
  105. class UnidentifiedImageError(OSError):
  106. """
  107. Raised in :py:meth:`PIL.Image.open` if an image cannot be opened and identified.
  108. """
  109. pass