From cee8fd07885d3684aeb0cf8bf966722d56e9e85b Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 16 Sep 2023 09:06:23 +1000 Subject: [PATCH] Improved init() and preinit() documentation --- docs/reference/Image.rst | 8 ++++++-- src/PIL/Image.py | 14 ++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/docs/reference/Image.rst b/docs/reference/Image.rst index 41d3b8fcec0..66e6b2a0c97 100644 --- a/docs/reference/Image.rst +++ b/docs/reference/Image.rst @@ -93,10 +93,14 @@ Generating images Registering plugins ^^^^^^^^^^^^^^^^^^^ +.. autofunction:: preinit +.. autofunction:: init + .. note:: - These functions are for use by plugin authors. Application authors can - ignore them. + These functions are for use by plugin authors. They are called when a + plugin is loaded as part of :py:meth:`~preinit()` or :py:meth:`~init()`. + Application authors can ignore them. .. autofunction:: register_open .. autofunction:: register_mime diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 9bf293d13e8..e2d460eeb3b 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -298,7 +298,11 @@ def getmodebands(mode): def preinit(): - """Explicitly load standard file format drivers.""" + """ + Explicitly loads BMP, GIF, JPEG, PPM and PPM file format drivers. + + It is called when opening or saving images. + """ global _initialized if _initialized >= 1: @@ -334,11 +338,6 @@ def preinit(): assert PngImagePlugin except ImportError: pass - # try: - # import TiffImagePlugin - # assert TiffImagePlugin - # except ImportError: - # pass _initialized = 1 @@ -347,6 +346,9 @@ def init(): """ Explicitly initializes the Python Imaging Library. This function loads all available file format drivers. + + It is called when opening or saving images if :py:meth:`~preinit()` is + insufficient, and by :py:meth:`~PIL.features.pilinfo`. """ global _initialized