# Pillow > Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/about.html # Path: about.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](index.html) [ ![Light Logo](_static/pillow-logo-dark-text.png) ![Dark Logo](_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](index.html) * [Installation](installation/index.html) * [Basic installation](installation/basic-installation.html) * [Python support](installation/python-support.html) * [Platform support](installation/platform-support.html) * [Building from source](installation/building-from-source.html) * [Old versions](installation/building-from-source.html#old-versions) * [Handbook](handbook/index.html) * [Overview](handbook/overview.html) * [Tutorial](handbook/tutorial.html) * [Concepts](handbook/concepts.html) * [Appendices](handbook/appendices.html) * [Image file formats](handbook/image-file-formats.html) * [Text anchors](handbook/text-anchors.html) * [Third-party plugins](handbook/third-party-plugins.html) * [Writing your own image plugin](handbook/writing-your-own-image-plugin.html) * [Decoders](handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](reference/index.html) * [`Image` module](reference/Image.html) * [`ImageChops` (“channel operations”) module](reference/ImageChops.html) * [`ImageCms` module](reference/ImageCms.html) * [`ImageColor` module](reference/ImageColor.html) * [`ImageDraw` module](reference/ImageDraw.html) * [`ImageEnhance` module](reference/ImageEnhance.html) * [`ImageFile` module](reference/ImageFile.html) * [`ImageFilter` module](reference/ImageFilter.html) * [`ImageFont` module](reference/ImageFont.html) * [`ImageGrab` module](reference/ImageGrab.html) * [`ImageMath` module](reference/ImageMath.html) * [`ImageMorph` module](reference/ImageMorph.html) * [`ImageOps` module](reference/ImageOps.html) * [`ImagePalette` module](reference/ImagePalette.html) * [`ImagePath` module](reference/ImagePath.html) * [`ImageQt` module](reference/ImageQt.html) * [`ImageSequence` module](reference/ImageSequence.html) * [`ImageShow` module](reference/ImageShow.html) * [`ImageStat` module](reference/ImageStat.html) * [`ImageText` module](reference/ImageText.html) * [`ImageTk` module](reference/ImageTk.html) * [`ImageTransform` module](reference/ImageTransform.html) * [`ImageWin` module (Windows-only)](reference/ImageWin.html) * [`ExifTags` module](reference/ExifTags.html) * [`TiffTags` module](reference/TiffTags.html) * [`JpegPresets` module](reference/JpegPresets.html) * [`PSDraw` module](reference/PSDraw.html) * [`PixelAccess` class](reference/PixelAccess.html) * [`features` module](reference/features.html) * [PIL package (autodoc of remaining modules)](PIL.html) * [Plugin reference](reference/plugins.html) * [Internal reference](reference/internal_design.html) * [File handling in Pillow](reference/open_files.html) * [Limits](reference/limits.html) * [Block allocator](reference/block_allocator.html) * [Internal modules](reference/internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](reference/c_extension_debugging.html) * [Arrow support](reference/arrow_support.html) * [Porting](porting.html) * About * [Release notes](releasenotes/index.html) * [Versioning](releasenotes/versioning.html) * [12.1.0 (unreleased)](releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](releasenotes/2.3.1.html) * [Deprecations and removals](deprecations.html) Back to top [ View this page ](_sources/about.rst.txt "View this page") # About¶ ## Goals¶ The fork author’s goal is to foster and support active development of PIL through: * Continuous integration testing via [GitHub Actions](https://github.com/python-pillow/Pillow/actions) * Publicized development activity on [GitHub](https://github.com/python-pillow/Pillow) * Regular releases to the [Python Package Index](https://pypi.org/project/pillow/) ## License¶ Like PIL, Pillow is [licensed under the open source MIT-CMU License](https://raw.githubusercontent.com/python-pillow/Pillow/main/LICENSE) ## Why a fork?¶ PIL is not setuptools compatible. Please see [this Image-SIG post](https://mail.python.org/pipermail/image-sig/2010-August/006480.html) for a more detailed explanation. Also, PIL’s bi-yearly (or greater) release schedule was too infrequent to accommodate the large number and frequency of issues reported. ## What about PIL?¶ Note Prior to Pillow 2.0.0, very few image code changes were made. Pillow 2.0.0 added Python 3 support and includes many bug fixes from many contributors. The last PIL release was in 2009 (1.1.7) and [no future releases are expected](https://github.com/python-pillow/Pillow/issues/1535). In January 2020, [the PyPI moderators exhausted the PEP 541 process for contacting the PIL project owner](https://github.com/python- pillow/Pillow/issues/1535#issuecomment-570308446) and the [PIL project on PyPI](https://pypi.org/project/PIL) was transferred to the [Pillow team](https://github.com/python-pillow/Pillow/graphs/contributors). The Pillow team has no plans to update the PIL project on PyPI. [ Next Release notes ](releasenotes/index.html) [ Previous Porting ](porting.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * About * Goals * License * Why a fork? * What about PIL? --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/handbook/appendices.html # Path: handbook/appendices.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](index.html) * [Overview](overview.html) * [Tutorial](tutorial.html) * [Concepts](concepts.html) * Appendices * [Image file formats](image-file-formats.html) * [Text anchors](text-anchors.html) * [Third-party plugins](third-party-plugins.html) * [Writing your own image plugin](writing-your-own-image-plugin.html) * [Decoders](writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](../reference/index.html) * [`Image` module](../reference/Image.html) * [`ImageChops` (“channel operations”) module](../reference/ImageChops.html) * [`ImageCms` module](../reference/ImageCms.html) * [`ImageColor` module](../reference/ImageColor.html) * [`ImageDraw` module](../reference/ImageDraw.html) * [`ImageEnhance` module](../reference/ImageEnhance.html) * [`ImageFile` module](../reference/ImageFile.html) * [`ImageFilter` module](../reference/ImageFilter.html) * [`ImageFont` module](../reference/ImageFont.html) * [`ImageGrab` module](../reference/ImageGrab.html) * [`ImageMath` module](../reference/ImageMath.html) * [`ImageMorph` module](../reference/ImageMorph.html) * [`ImageOps` module](../reference/ImageOps.html) * [`ImagePalette` module](../reference/ImagePalette.html) * [`ImagePath` module](../reference/ImagePath.html) * [`ImageQt` module](../reference/ImageQt.html) * [`ImageSequence` module](../reference/ImageSequence.html) * [`ImageShow` module](../reference/ImageShow.html) * [`ImageStat` module](../reference/ImageStat.html) * [`ImageText` module](../reference/ImageText.html) * [`ImageTk` module](../reference/ImageTk.html) * [`ImageTransform` module](../reference/ImageTransform.html) * [`ImageWin` module (Windows-only)](../reference/ImageWin.html) * [`ExifTags` module](../reference/ExifTags.html) * [`TiffTags` module](../reference/TiffTags.html) * [`JpegPresets` module](../reference/JpegPresets.html) * [`PSDraw` module](../reference/PSDraw.html) * [`PixelAccess` class](../reference/PixelAccess.html) * [`features` module](../reference/features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](../reference/plugins.html) * [Internal reference](../reference/internal_design.html) * [File handling in Pillow](../reference/open_files.html) * [Limits](../reference/limits.html) * [Block allocator](../reference/block_allocator.html) * [Internal modules](../reference/internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](../reference/c_extension_debugging.html) * [Arrow support](../reference/arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/handbook/appendices.rst.txt "View this page") # Appendices¶ Note Contributors please include appendices as needed or appropriate with your bug fixes, feature additions and tests. * [Image file formats](image-file-formats.html) * [Fully supported formats](image-file-formats.html#fully-supported-formats) * [Read-only formats](image-file-formats.html#read-only-formats) * [Write-only formats](image-file-formats.html#write-only-formats) * [Identify-only formats](image-file-formats.html#identify-only-formats) * [Text anchors](text-anchors.html) * [Specifying an anchor](text-anchors.html#specifying-an-anchor) * [Quick reference](text-anchors.html#quick-reference) * [Horizontal anchor alignment](text-anchors.html#horizontal-anchor-alignment) * [Vertical anchor alignment](text-anchors.html#vertical-anchor-alignment) * [Examples](text-anchors.html#examples) * [Third-party plugins](third-party-plugins.html) * [Writing your own image plugin](writing-your-own-image-plugin.html) * [Example](writing-your-own-image-plugin.html#example) * [The `tile` attribute](writing-your-own-image-plugin.html#the-tile-attribute) * [Decoders](writing-your-own-image-plugin.html#decoders) * [The raw decoder](writing-your-own-image-plugin.html#the-raw-decoder) * [Decoding floating point data](writing-your-own-image-plugin.html#decoding-floating-point-data) * [The bit decoder](writing-your-own-image-plugin.html#the-bit-decoder) * [Writing your own file codec in C](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Setup](writing-your-own-image-plugin.html#setup) * [Transforming](writing-your-own-image-plugin.html#transforming) * [Cleanup](writing-your-own-image-plugin.html#cleanup) * [Writing your own file codec in Python](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) [ Next Image file formats ](image-file-formats.html) [ Previous Concepts ](concepts.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/handbook/concepts.html # Path: handbook/concepts.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](index.html) * [Overview](overview.html) * [Tutorial](tutorial.html) * Concepts * [Appendices](appendices.html) * [Image file formats](image-file-formats.html) * [Text anchors](text-anchors.html) * [Third-party plugins](third-party-plugins.html) * [Writing your own image plugin](writing-your-own-image-plugin.html) * [Decoders](writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](../reference/index.html) * [`Image` module](../reference/Image.html) * [`ImageChops` (“channel operations”) module](../reference/ImageChops.html) * [`ImageCms` module](../reference/ImageCms.html) * [`ImageColor` module](../reference/ImageColor.html) * [`ImageDraw` module](../reference/ImageDraw.html) * [`ImageEnhance` module](../reference/ImageEnhance.html) * [`ImageFile` module](../reference/ImageFile.html) * [`ImageFilter` module](../reference/ImageFilter.html) * [`ImageFont` module](../reference/ImageFont.html) * [`ImageGrab` module](../reference/ImageGrab.html) * [`ImageMath` module](../reference/ImageMath.html) * [`ImageMorph` module](../reference/ImageMorph.html) * [`ImageOps` module](../reference/ImageOps.html) * [`ImagePalette` module](../reference/ImagePalette.html) * [`ImagePath` module](../reference/ImagePath.html) * [`ImageQt` module](../reference/ImageQt.html) * [`ImageSequence` module](../reference/ImageSequence.html) * [`ImageShow` module](../reference/ImageShow.html) * [`ImageStat` module](../reference/ImageStat.html) * [`ImageText` module](../reference/ImageText.html) * [`ImageTk` module](../reference/ImageTk.html) * [`ImageTransform` module](../reference/ImageTransform.html) * [`ImageWin` module (Windows-only)](../reference/ImageWin.html) * [`ExifTags` module](../reference/ExifTags.html) * [`TiffTags` module](../reference/TiffTags.html) * [`JpegPresets` module](../reference/JpegPresets.html) * [`PSDraw` module](../reference/PSDraw.html) * [`PixelAccess` class](../reference/PixelAccess.html) * [`features` module](../reference/features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](../reference/plugins.html) * [Internal reference](../reference/internal_design.html) * [File handling in Pillow](../reference/open_files.html) * [Limits](../reference/limits.html) * [Block allocator](../reference/block_allocator.html) * [Internal modules](../reference/internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](../reference/c_extension_debugging.html) * [Arrow support](../reference/arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/handbook/concepts.rst.txt "View this page") # Concepts¶ The Python Imaging Library handles _raster images_ ; that is, rectangles of pixel data. ## Bands¶ An image can consist of one or more bands of data. The Python Imaging Library allows you to store several bands in a single image, provided they all have the same dimensions and depth. For example, a PNG image might have ‘R’, ‘G’, ‘B’, and ‘A’ bands for the red, green, blue, and alpha transparency values. Many operations act on each band separately, e.g., histograms. It is often useful to think of each pixel as having one value per band. To get the number and names of bands in an image, use the [`getbands()`](../reference/Image.html#PIL.Image.Image.getbands "PIL.Image.Image.getbands") method. ## Modes¶ The `mode` of an image is a string which defines the type and depth of a pixel in the image. Each pixel uses the full range of the bit depth. So a 1-bit pixel has a range of 0-1, an 8-bit pixel has a range of 0-255, a 32-signed integer pixel has the range of INT32 and a 32-bit floating point pixel has the range of FLOAT32. The current release supports the following standard modes: * `1` (1-bit pixels, black and white, stored with one pixel per byte) * `L` (8-bit pixels, grayscale) * `P` (8-bit pixels, mapped to any other mode using a color palette) * `RGB` (3x8-bit pixels, true color) * `RGBA` (4x8-bit pixels, true color with transparency mask) * `CMYK` (4x8-bit pixels, color separation) * `YCbCr` (3x8-bit pixels, color video format) * Note that this refers to the JPEG, and not the ITU-R BT.2020, standard * `LAB` (3x8-bit pixels, the L*a*b color space) * `HSV` (3x8-bit pixels, Hue, Saturation, Value color space) * Hue’s range of 0-255 is a scaled version of 0 degrees <= Hue < 360 degrees * `I` (32-bit signed integer pixels) * `F` (32-bit floating point pixels) Pillow also provides limited support for a few additional modes, including: * `LA` (L with alpha) * `PA` (P with alpha) * `RGBX` (true color with padding) * `RGBa` (true color with premultiplied alpha) * `La` (L with premultiplied alpha) * `I;16` (16-bit unsigned integer pixels) * `I;16L` (16-bit little endian unsigned integer pixels) * `I;16B` (16-bit big endian unsigned integer pixels) * `I;16N` (16-bit native endian unsigned integer pixels) Premultiplied alpha is where the values for each other channel have been multiplied by the alpha. For example, an RGBA pixel of `(10, 20, 30, 127)` would convert to an RGBa pixel of `(5, 10, 15, 127)`. The values of the R, G and B channels are halved as a result of the half transparency in the alpha channel. Apart from these additional modes, Pillow doesn’t yet support multichannel images with a depth of more than 8 bits per channel. Pillow also doesn’t support user-defined modes; if you need to handle band combinations that are not listed above, use a sequence of Image objects. You can read the mode of an image through the [`mode`](../reference/Image.html#PIL.Image.Image.mode "PIL.Image.Image.mode") attribute. This is a string containing one of the above values. ## Size¶ You can read the image size through the [`size`](../reference/Image.html#PIL.Image.Image.size "PIL.Image.Image.size") attribute. This is a 2-tuple, containing the horizontal and vertical size in pixels. ## Coordinate system¶ The Python Imaging Library uses a Cartesian pixel coordinate system, with (0,0) in the upper left corner. Note that the coordinates refer to the implied pixel corners; the centre of a pixel addressed as (0, 0) actually lies at (0.5, 0.5). Coordinates are usually passed to the library as 2-tuples (x, y). Rectangles are represented as 4-tuples, (x1, y1, x2, y2), with the upper left corner given first. ## Palette¶ The palette mode (`P`) uses a color palette to define the actual color for each pixel. ## Colors¶ To specify colors, you can use tuples with a value for each channel in the image, e.g. `Image.new("RGB", (1, 1), (255, 0, 0))`. If an image has a single channel, you can use a single number instead, e.g. `Image.new("L", (1, 1), 255)`. For “F” mode images, floating point values are also accepted. In the case of “P” mode images, these will be indexes for the color palette. If a single value is used for an image with more than one channel, it will still be parsed: >>> from PIL import Image >>> im = Image.new("RGBA", (1, 1), 0x04030201) >>> im.getpixel((0, 0)) (1, 2, 3, 4) Some methods accept other forms, such as color names. See [Color names](../reference/ImageColor.html#color-names). ## Info¶ You can attach auxiliary information to an image using the [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") attribute. This is a dictionary object. How such information is handled when loading and saving image files is up to the file format handler (see the chapter on [Image file formats](image-file- formats.html#image-file-formats)). Most handlers add properties to the [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") attribute when loading an image, but ignore it when saving images. ## Transparency¶ If an image does not have an alpha band, transparency may be specified in the [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") attribute with a “transparency” key. Most of the time, the “transparency” value is a single integer, describing which pixel value is transparent in a “1”, “L”, “I” or “P” mode image. However, PNG images may have three values, one for each channel in an “RGB” mode image, or can have a byte string for a “P” mode image, to specify the alpha value for each palette entry. ## Orientation¶ A common element of the [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") attribute for JPG and TIFF images is the EXIF orientation tag. This is an instruction for how the image data should be oriented. For example, it may instruct an image to be rotated by 90 degrees, or to be mirrored. To apply this information to an image, [`exif_transpose()`](../reference/ImageOps.html#PIL.ImageOps.exif_transpose "PIL.ImageOps.exif_transpose") can be used. ## Filters¶ For geometry operations that may map multiple input pixels to a single output pixel, the Python Imaging Library provides different resampling _filters_. Resampling.NEAREST Pick one nearest pixel from the input image. Ignore all other input pixels. Resampling.BOX Each pixel of source image contributes to one pixel of the destination image with identical weights. For upscaling is equivalent of [`Resampling.NEAREST`](../reference/Image.html#PIL.Image.Resampling.NEAREST "PIL.Image.Resampling.NEAREST"). This filter can only be used with the [`resize()`](../reference/Image.html#PIL.Image.Image.resize "PIL.Image.Image.resize") and [`thumbnail()`](../reference/Image.html#PIL.Image.Image.thumbnail "PIL.Image.Image.thumbnail") methods. Added in version 3.4.0. Resampling.BILINEAR For resize calculate the output pixel value using linear interpolation on all pixels that may contribute to the output value. For other transformations linear interpolation over a 2x2 environment in the input image is used. Resampling.HAMMING Produces a sharper image than [`Resampling.BILINEAR`](../reference/Image.html#PIL.Image.Resampling.BILINEAR "PIL.Image.Resampling.BILINEAR"), doesn’t have dislocations on local level like with [`Resampling.BOX`](../reference/Image.html#PIL.Image.Resampling.BOX "PIL.Image.Resampling.BOX"). This filter can only be used with the [`resize()`](../reference/Image.html#PIL.Image.Image.resize "PIL.Image.Image.resize") and [`thumbnail()`](../reference/Image.html#PIL.Image.Image.thumbnail "PIL.Image.Image.thumbnail") methods. Added in version 3.4.0. Resampling.BICUBIC For resize calculate the output pixel value using cubic interpolation on all pixels that may contribute to the output value. For other transformations cubic interpolation over a 4x4 environment in the input image is used. Resampling.LANCZOS Calculate the output pixel value using a high-quality Lanczos filter (a truncated sinc) on all pixels that may contribute to the output value. This filter can only be used with the [`resize()`](../reference/Image.html#PIL.Image.Image.resize "PIL.Image.Image.resize") and [`thumbnail()`](../reference/Image.html#PIL.Image.Image.thumbnail "PIL.Image.Image.thumbnail") methods. Added in version 1.1.3. ### Filters comparison table¶ Filter | Downscaling quality | Upscaling quality | Performance ---|---|---|--- [`Resampling.NEAREST`](../reference/Image.html#PIL.Image.Resampling.NEAREST "PIL.Image.Resampling.NEAREST") | | | ⭐⭐⭐⭐⭐ [`Resampling.BOX`](../reference/Image.html#PIL.Image.Resampling.BOX "PIL.Image.Resampling.BOX") | ⭐ | | ⭐⭐⭐⭐ [`Resampling.BILINEAR`](../reference/Image.html#PIL.Image.Resampling.BILINEAR "PIL.Image.Resampling.BILINEAR") | ⭐ | ⭐ | ⭐⭐⭐ [`Resampling.HAMMING`](../reference/Image.html#PIL.Image.Resampling.HAMMING "PIL.Image.Resampling.HAMMING") | ⭐⭐ | | ⭐⭐⭐ [`Resampling.BICUBIC`](../reference/Image.html#PIL.Image.Resampling.BICUBIC "PIL.Image.Resampling.BICUBIC") | ⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐ [`Resampling.LANCZOS`](../reference/Image.html#PIL.Image.Resampling.LANCZOS "PIL.Image.Resampling.LANCZOS") | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐ [ Next Appendices ](appendices.html) [ Previous Tutorial ](tutorial.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * Concepts * Bands * Modes * Size * Coordinate system * Palette * Colors * Info * Transparency * Orientation * Filters * Filters comparison table --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/handbook/image-file-formats.html # Path: handbook/image-file-formats.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](index.html) * [Overview](overview.html) * [Tutorial](tutorial.html) * [Concepts](concepts.html) * [Appendices](appendices.html) * Image file formats * [Text anchors](text-anchors.html) * [Third-party plugins](third-party-plugins.html) * [Writing your own image plugin](writing-your-own-image-plugin.html) * [Decoders](writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](../reference/index.html) * [`Image` module](../reference/Image.html) * [`ImageChops` (“channel operations”) module](../reference/ImageChops.html) * [`ImageCms` module](../reference/ImageCms.html) * [`ImageColor` module](../reference/ImageColor.html) * [`ImageDraw` module](../reference/ImageDraw.html) * [`ImageEnhance` module](../reference/ImageEnhance.html) * [`ImageFile` module](../reference/ImageFile.html) * [`ImageFilter` module](../reference/ImageFilter.html) * [`ImageFont` module](../reference/ImageFont.html) * [`ImageGrab` module](../reference/ImageGrab.html) * [`ImageMath` module](../reference/ImageMath.html) * [`ImageMorph` module](../reference/ImageMorph.html) * [`ImageOps` module](../reference/ImageOps.html) * [`ImagePalette` module](../reference/ImagePalette.html) * [`ImagePath` module](../reference/ImagePath.html) * [`ImageQt` module](../reference/ImageQt.html) * [`ImageSequence` module](../reference/ImageSequence.html) * [`ImageShow` module](../reference/ImageShow.html) * [`ImageStat` module](../reference/ImageStat.html) * [`ImageText` module](../reference/ImageText.html) * [`ImageTk` module](../reference/ImageTk.html) * [`ImageTransform` module](../reference/ImageTransform.html) * [`ImageWin` module (Windows-only)](../reference/ImageWin.html) * [`ExifTags` module](../reference/ExifTags.html) * [`TiffTags` module](../reference/TiffTags.html) * [`JpegPresets` module](../reference/JpegPresets.html) * [`PSDraw` module](../reference/PSDraw.html) * [`PixelAccess` class](../reference/PixelAccess.html) * [`features` module](../reference/features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](../reference/plugins.html) * [Internal reference](../reference/internal_design.html) * [File handling in Pillow](../reference/open_files.html) * [Limits](../reference/limits.html) * [Block allocator](../reference/block_allocator.html) * [Internal modules](../reference/internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](../reference/c_extension_debugging.html) * [Arrow support](../reference/arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/handbook/image-file-formats.rst.txt "View this page") # Image file formats¶ The Python Imaging Library supports a wide variety of raster file formats. Over 30 different file formats can be identified and read by the library. Write support is less extensive, but most common interchange and presentation formats are supported. The [`open()`](../reference/Image.html#PIL.Image.open "PIL.Image.open") function identifies files from their contents, not their names, but the [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") method looks at the name to determine which format to use, unless the format is given explicitly. When an image is opened from a file, only that instance of the image is considered to have the format. Copies of the image will contain data loaded from the file, but not the file itself, meaning that it can no longer be considered to be in the original format. So if [`copy()`](../reference/Image.html#PIL.Image.Image.copy "PIL.Image.Image.copy") is called on an image, or another method internally creates a copy of the image, then any methods or attributes specific to the format will no longer be present. The `fp` (file pointer) attribute will no longer be present, and the [`format`](../reference/Image.html#PIL.Image.Image.format "PIL.Image.Image.format") attribute will be `None`. ## Fully supported formats¶ ### AVIF¶ Pillow reads and writes AVIF files, including AVIF sequence images. It is only possible to save 8-bit AVIF images, and all AVIF images are decoded as 8-bit RGB(A). The [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") method supports the following options: **quality** Integer, 0-100, defaults to 75. 0 gives the smallest size and poorest quality, 100 the largest size and best quality. **subsampling** If present, sets the subsampling for the encoder. Defaults to `4:2:0`. Options include: * `4:0:0` * `4:2:0` * `4:2:2` * `4:4:4` **speed** Quality/speed trade-off (0=slower/better, 10=fastest). Defaults to 6. **max_threads** Limit the number of active threads used. By default, there is no limit. If the aom codec is used, there is a maximum of 64. **range** YUV range, either “full” or “limited”. Defaults to “full”. **codec** AV1 codec to use for encoding. Specific values are “aom”, “rav1e”, and “svt”, presuming the chosen codec is available. Defaults to “auto”, which will choose the first available codec in the order of the preceding list. **tile_rows** / **tile_cols** For tile encoding, the (log 2) number of tile rows and columns to use. Valid values are 0-6, default 0. Ignored if “autotiling” is set to true. **autotiling** Split the image up to allow parallelization. Enabled automatically if “tile_rows” and “tile_cols” both have their default values of zero. **alpha_premultiplied** Encode the image with premultiplied alpha. Defaults to `False`. **advanced** Codec specific options. **icc_profile** The ICC Profile to include in the saved file. **exif** The exif data to include in the saved file. **xmp** The XMP data to include in the saved file. #### Saving sequences¶ When calling [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") to write an AVIF file, by default only the first frame of a multiframe image will be saved. If the `save_all` argument is present and true, then all frames will be saved, and the following options will also be available. **append_images** A list of images to append as additional frames. Each of the images in the list can be single or multiframe images. **duration** The display duration of each frame, in milliseconds. Pass a single integer for a constant duration, or a list or tuple to set the duration for each frame separately. ### BLP¶ BLP is the Blizzard Mipmap Format, a texture format used in World of Warcraft. Pillow supports reading `JPEG` Compressed or raw `BLP1` images, and all types of `BLP2` images. #### Saving¶ Pillow supports writing BLP images. The [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") method can take the following keyword arguments: **blp_version** If present and set to “BLP1”, images will be saved as BLP1. Otherwise, images will be saved as BLP2. ### BMP¶ Pillow reads and writes Windows and OS/2 BMP files containing `1`, `L`, `P`, or `RGB` data. 16-colour images are read as `P` images. Support for reading 8-bit run-length encoding was added in Pillow 9.1.0. Support for reading 4-bit run-length encoding was added in Pillow 9.3.0. #### Opening¶ The [`open()`](../reference/Image.html#PIL.Image.open "PIL.Image.open") method sets the following [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") properties: **compression** Set to 1 if the file is a 256-color run-length encoded image. Set to 2 if the file is a 16-color run-length encoded image. ### DDS¶ DDS is a popular container texture format used in video games and natively supported by DirectX. DXT1 and DXT5 pixel formats can be read, only in `RGBA` mode. Added in version 3.4.0: DXT3 images can be read in `RGBA` mode and DX10 images can be read in `RGB` and `RGBA` mode. Added in version 6.0.0: Uncompressed `RGBA` images can be read. Added in version 8.3.0: BC5S images can be opened in `RGB` mode, and uncompressed `RGB` images can be read. Uncompressed data can also be saved to image files. Added in version 9.3.0: ATI1 images can be opened in `L` mode and ATI2 images can be opened in `RGB` mode. Added in version 9.4.0: Uncompressed `L` (“luminance”) and `LA` images can be opened and saved. Added in version 10.1.0: BC5U can be read in `RGB` mode, and 8-bit color indexed images can be read in `P` mode. Added in version 11.2.1: DXT1, DXT3, DXT5, BC2, BC3 and BC5 pixel formats can be saved:: > im.save(out, pixel_format=”DXT1”) ### DIB¶ Pillow reads and writes DIB files. DIB files are similar to BMP files, so see above for more information. > Added in version 6.0.0. ### EPS¶ Pillow identifies EPS files containing image data, and can read files that contain embedded raster images (ImageData descriptors). If Ghostscript is available, other EPS files can be read as well. The EPS driver can also write EPS images. The EPS driver can read EPS images in `L`, `LAB`, `RGB` and `CMYK` mode, but Ghostscript may convert the images to `RGB` mode rather than leaving them in the original color space. The EPS driver can write images in `L`, `RGB` and `CMYK` modes. #### Loading¶ To use Ghostscript, Pillow searches for the “gs” executable. On Windows, it also searches for “gswin32c” and “gswin64c”. To customise this behaviour, `EpsImagePlugin.gs_binary = "gswin64"` will set the name of the executable to use. `EpsImagePlugin.gs_binary = False` will prevent Ghostscript use. If Ghostscript is available, you can call the [`load()`](../reference/Image.html#PIL.Image.Image.load "PIL.Image.Image.load") method with the following parameters to affect how Ghostscript renders the EPS. **scale** Affects the scale of the resultant rasterized image. If the EPS suggests that the image be rendered at 100px x 100px, setting this parameter to 2 will make the Ghostscript render a 200px x 200px image instead. The relative position of the bounding box is maintained: im = Image.open(...) im.size # (100,100) im.load(scale=2) im.size # (200,200) **transparency** If true, generates an RGBA image with a transparent background, instead of the default behaviour of an RGB image with a white background. ### GIF¶ Pillow reads GIF87a and GIF89a versions of the GIF file format. The library writes files in GIF87a by default, unless GIF89a features are used or GIF89a is already in use. Files are written with LZW encoding. GIF files are initially read as grayscale (`L`) or palette mode (`P`) images. Seeking to later frames in a `P` image will change the image to `RGB` (or `RGBA` if the first frame had transparency). `P` mode images are changed to `RGB` because each frame of a GIF may contain its own individual palette of up to 256 colors. When a new frame is placed onto a previous frame, those colors may combine to exceed the `P` mode limit of 256 colors. Instead, the image is converted to `RGB` handle this. If you would prefer the first `P` image frame to be `RGB` as well, so that every `P` frame is converted to `RGB` or `RGBA` mode, there is a setting available: from PIL import GifImagePlugin GifImagePlugin.LOADING_STRATEGY = GifImagePlugin.LoadingStrategy.RGB_ALWAYS GIF frames do not always contain individual palettes however. If there is only a global palette, then all of the colors can fit within `P` mode. If you would prefer the frames to be kept as `P` in that case, there is also a setting available: from PIL import GifImagePlugin GifImagePlugin.LOADING_STRATEGY = GifImagePlugin.LoadingStrategy.RGB_AFTER_DIFFERENT_PALETTE_ONLY To restore the default behavior, where `P` mode images are only converted to `RGB` or `RGBA` after the first frame: from PIL import GifImagePlugin GifImagePlugin.LOADING_STRATEGY = GifImagePlugin.LoadingStrategy.RGB_AFTER_FIRST #### Opening¶ The [`open()`](../reference/Image.html#PIL.Image.open "PIL.Image.open") method sets the following [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") properties: **background** Default background color (a palette color index). **transparency** Transparency color index. This key is omitted if the image is not transparent. **version** Version (either `GIF87a` or `GIF89a`). **duration** May not be present. The time to display the current frame of the GIF, in milliseconds. **loop** May not be present. The number of times the GIF should loop. 0 means that it will loop forever. **comment** May not be present. A comment about the image. This is the last comment found before the current frame’s image. **extension** May not be present. Contains application specific information. #### Reading sequences¶ The GIF loader supports the [`seek()`](../reference/Image.html#PIL.Image.Image.seek "PIL.Image.Image.seek") and [`tell()`](../reference/Image.html#PIL.Image.Image.tell "PIL.Image.Image.tell") methods. You can combine these methods to seek to the next frame (`im.seek(im.tell() + 1)`). `im.seek()` raises an [`EOFError`](https://docs.python.org/3/library/exceptions.html#EOFError "\(in Python v3.14\)") if you try to seek after the last frame. #### Saving¶ When calling [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") to write a GIF file, the following options are available: im.save(out, save_all=True, append_images=[im1, im2, ...]) **save_all** If present and true, or if `append_images` is not empty, all frames of the image will be saved. Otherwise, only the first frame of a multiframe image will be saved. **append_images** A list of images to append as additional frames. Each of the images in the list can be single or multiframe images. This is supported for AVIF, GIF, PDF, PNG, TIFF and WebP. It is also supported for ICO and ICNS. If images are passed in of relevant sizes, they will be used instead of scaling down the main image. **include_color_table** Whether or not to include local color table. **interlace** Whether or not the image is interlaced. By default, it is, unless the image is less than 16 pixels in width or height. **disposal** Indicates the way in which the graphic is to be treated after being displayed. * 0 - No disposal specified. * 1 - Do not dispose. * 2 - Restore to background color. * 3 - Restore to previous content. > Pass a single integer for a constant disposal, or a list or tuple to set the > disposal for each frame separately. **palette** Use the specified palette for the saved image. The palette should be a bytes or bytearray object containing the palette entries in RGBRGB… form. It should be no more than 768 bytes. Alternately, the palette can be passed in as an [`PIL.ImagePalette.ImagePalette`](../reference/ImagePalette.html#PIL.ImagePalette.ImagePalette "PIL.ImagePalette.ImagePalette") object. **optimize** Whether to attempt to compress the palette by eliminating unused colors (this is only useful if the palette can be compressed to the next smaller power of 2 elements) and whether to mark all pixels that are not new in the next frame as transparent. This is attempted by default, unless a palette is specified as an option or as part of the first image’s [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") dictionary. Note that if the image you are saving comes from an existing GIF, it may have the following properties in its [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") dictionary. For these options, if you do not pass them in, they will default to their [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") values. **transparency** Transparency color index. **duration** The display duration of each frame of the multiframe gif, in milliseconds. Pass a single integer for a constant duration, or a list or tuple to set the duration for each frame separately. **loop** Integer number of times the GIF should loop. 0 means that it will loop forever. If omitted or `None`, the image will not loop. **comment** A comment about the image. #### Reading local images¶ 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 image. If you only want the actual pixel rectangle, you can crop the image: im = Image.open(...) if im.tile[0][0] == "gif": # only read the first "local image" from this GIF file box = im.tile[0][1] im = im.crop(box) ### ICNS¶ Pillow reads and writes macOS `.icns` files. By default, the largest available icon is read, though you can override this by setting the [`size`](../reference/Image.html#PIL.Image.Image.size "PIL.Image.Image.size") property before calling [`load()`](../reference/Image.html#PIL.Image.Image.load "PIL.Image.Image.load"). The [`open()`](../reference/Image.html#PIL.Image.open "PIL.Image.open") method sets the following [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") property: Note Prior to version 8.3.0, Pillow could only write ICNS files on macOS. **sizes** A list of supported sizes found in this icon file; these are a 3-tuple, `(width, height, scale)`, where `scale` is 2 for a retina icon and 1 for a standard icon. #### Loading¶ You can call the [`load()`](../reference/Image.html#PIL.Image.Image.load "PIL.Image.Image.load") method with the following parameter. **scale** Affects the scale of the resultant image. If the size is set to `(512, 512)`, after loading at scale 2, the final value of [`size`](../reference/Image.html#PIL.Image.Image.size "PIL.Image.Image.size") will be `(1024, 1024)`. #### Saving¶ The [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") method can take the following keyword arguments: **append_images** A list of images to replace the scaled down versions of the image. The order of the images does not matter, as their use is determined by the size of each image. Added in version 5.1.0. ### ICO¶ ICO is used to store icons on Windows. The largest available icon is read. #### Saving¶ The [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") method supports the following options: **sizes** A list of sizes including in this ico file; these are a 2-tuple, `(width, height)`; Default to `[(16, 16), (24, 24), (32, 32), (48, 48), (64, 64), (128, 128), (256, 256)]`. Any sizes bigger than the original size or 256 will be ignored. The [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") method can take the following keyword arguments: **append_images** A list of images to replace the scaled down versions of the image. The order of the images does not matter, as their use is determined by the size of each image. Added in version 8.1.0. **bitmap_format** By default, the image data will be saved in PNG format. With a bitmap format of “bmp”, image data will be saved in BMP format instead. Added in version 8.3.0. ### IM¶ IM is a format used by LabEye and other applications based on the IFUNC image processing library. The library reads and writes most uncompressed interchange versions of this format. IM is the only format that can store all internal Pillow formats. ### JPEG¶ Pillow reads JPEG, JFIF, and Adobe JPEG files containing `L`, `RGB`, or `CMYK` data. It writes standard and progressive JFIF files. Using the [`draft()`](../reference/Image.html#PIL.Image.Image.draft "PIL.Image.Image.draft") method, you can speed things up by converting `RGB` images to `L`, and resize images to 1/2, 1/4 or 1/8 of their original size while loading them. By default Pillow doesn’t allow loading of truncated JPEG files, set [`ImageFile.LOAD_TRUNCATED_IMAGES`](../reference/ImageFile.html#PIL.ImageFile.LOAD_TRUNCATED_IMAGES "PIL.ImageFile.LOAD_TRUNCATED_IMAGES") to override this. #### Opening¶ The [`open()`](../reference/Image.html#PIL.Image.open "PIL.Image.open") method may set the following [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") properties if available: **jfif** JFIF application marker found. If the file is not a JFIF file, this key is not present. **jfif_version** A tuple representing the jfif version, (major version, minor version). **jfif_density** A tuple representing the pixel density of the image, in units specified by jfif_unit. **jfif_unit** Units for the jfif_density: * 0 - No Units * 1 - Pixels per Inch * 2 - Pixels per Centimeter **dpi** A tuple representing the reported pixel density in pixels per inch, if the file is a jfif file and the units are in inches. **adobe** Adobe application marker found. If the file is not an Adobe JPEG file, this key is not present. **adobe_transform** Vendor Specific Tag. **progression** Indicates that this is a progressive JPEG file. **icc_profile** The ICC color profile for the image. **exif** Raw EXIF data from the image. **comment** A comment about the image, from the COM marker. This is separate from the UserComment tag that may be stored in the EXIF data. Added in version 7.1.0. #### Saving¶ The [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") method supports the following options: **quality** The image quality, on a scale from 0 (worst) to 95 (best), or the string `keep`. The default is 75. Values above 95 should be avoided; 100 disables portions of the JPEG compression algorithm, and results in large files with hardly any gain in image quality. The value `keep` is only valid for JPEG files and will retain the original image quality level, subsampling, and qtables. For more information on how qtables are modified based on the quality parameter, see the qtables section. **optimize** If present and true, indicates that the encoder should make an extra pass over the image in order to select optimal encoder settings. **progressive** If present and true, indicates that this image should be stored as a progressive JPEG file. **dpi** A tuple of integers representing the pixel density, `(x,y)`. **icc_profile** If present and true, the image is stored with the provided ICC profile. If this parameter is not provided, the image will be saved with no profile attached. To preserve the existing profile: im.save(filename, 'jpeg', icc_profile=im.info.get('icc_profile')) **exif** If present, the image will be stored with the provided raw EXIF data. **keep_rgb** By default, libjpeg converts images with an RGB color space to YCbCr. If this option is present and true, those images will be stored as RGB instead. When this option is enabled, attempting to chroma-subsample RGB images with the `subsampling` option will raise an [`OSError`](https://docs.python.org/3/library/exceptions.html#OSError "\(in Python v3.14\)"). Added in version 10.2.0. **subsampling** If present, sets the subsampling for the encoder. * `keep`: Only valid for JPEG files, will retain the original image setting. * `4:4:4`, `4:2:2`, `4:2:0`: Specific sampling values * `0`: equivalent to `4:4:4` * `1`: equivalent to `4:2:2` * `2`: equivalent to `4:2:0` If absent, the setting will be determined by libjpeg or libjpeg-turbo. **restart_marker_blocks** If present, emit a restart marker whenever the specified number of MCU blocks has been produced. Added in version 10.2.0. **restart_marker_rows** If present, emit a restart marker whenever the specified number of MCU rows has been produced. Added in version 10.2.0. **qtables** If present, sets the qtables for the encoder. This is listed as an advanced option for wizards in the JPEG documentation. Use with caution. `qtables` can be one of several types of values: * a string, naming a preset, e.g. `keep`, `web_low`, or `web_high` * a list, tuple, or dictionary (with integer keys = range(len(keys))) of lists of 64 integers. There must be between 2 and 4 tables. If a quality parameter is provided, the qtables will be adjusted accordingly. By default, the qtables are based on a standard JPEG table with a quality of 50. The qtable values will be reduced if the quality is higher than 50 and increased if the quality is lower than 50. Added in version 2.5.0. **streamtype** Allows storing images without quantization and Huffman tables, or with these tables but without image data. This is useful for container formats or network protocols that handle tables separately and share them between images. * `0` (default): interchange datastream, with tables and image data * `1`: abbreviated table specification (tables-only) datastream Added in version 10.2.0. * `2`: abbreviated image (image-only) datastream **comment** A comment about the image. Added in version 9.4.0. Note To enable JPEG support, you need to build and install the IJG JPEG library before building the Python Imaging Library. See the distribution README for details. ### JPEG 2000¶ Added in version 2.4.0. Pillow reads and writes JPEG 2000 files containing `L`, `LA`, `RGB`, `RGBA`, or `YCbCr` data. When reading, `YCbCr` data is converted to `RGB` or `RGBA` depending on whether or not there is an alpha channel. Added in version 8.3.0: Pillow can read (but not write) `RGB`, `RGBA`, and `YCbCr` images with subsampled components. Added in version 10.4.0: Pillow can read `CMYK` images with OpenJPEG 2.5.1 and later. Added in version 11.1.0: Pillow can write `CMYK` images with OpenJPEG 2.5.3 and later. Pillow supports JPEG 2000 raw codestreams (`.j2k` files), as well as boxed JPEG 2000 files (`.jp2` or `.jpx` files). When loading, if you set the `mode` on the image prior to the [`load()`](../reference/Image.html#PIL.Image.Image.load "PIL.Image.Image.load") method being invoked, you can ask Pillow to convert the image to either `RGB` or `RGBA` rather than choosing for itself. It is also possible to set `reduce` to the number of resolutions to discard (each one reduces the size of the resulting image by a factor of 2), and `layers` to specify the number of quality layers to load. #### Saving¶ The [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") method supports the following options: **offset** The image offset, as a tuple of integers, e.g. (16, 16) **tile_offset** The tile offset, again as a 2-tuple of integers. **tile_size** The tile size as a 2-tuple. If not specified, or if set to None, the image will be saved without tiling. **quality_mode** Either `"rates"` or `"dB"` depending on the units you want to use to specify image quality. **quality_layers** A sequence of numbers, each of which represents either an approximate size reduction (if quality mode is `"rates"`) or a signal to noise ratio value in decibels. If not specified, defaults to a single layer of full quality. **num_resolutions** The number of different image resolutions to be stored (which corresponds to the number of Discrete Wavelet Transform decompositions plus one). **codeblock_size** The code-block size as a 2-tuple. Minimum size is 4 x 4, maximum is 1024 x 1024, with the additional restriction that no code-block may have more than 4096 coefficients (i.e. the product of the two numbers must be no greater than 4096). **precinct_size** The precinct size as a 2-tuple. Must be a power of two along both axes, and must be greater than the code-block size. **irreversible** If `True`, use the lossy discrete waveform transformation DWT 9-7. Defaults to `False`, which uses the lossless DWT 5-3. **mct** If `1` then enable multiple component transformation when encoding, otherwise use `0` for no component transformation (default). If MCT is enabled and `irreversible` is `True` then the Irreversible Color Transformation will be applied, otherwise encoding will use the Reversible Color Transformation. MCT works best with a `mode` of `RGB` and is only applicable when the image data has 3 components. Added in version 9.1.0. **progression** Controls the progression order; must be one of `"LRCP"`, `"RLCP"`, `"RPCL"`, `"PCRL"`, `"CPRL"`. The letters stand for Component, Position, Resolution and Layer respectively and control the order of encoding, the idea being that e.g. an image encoded using LRCP mode can have its quality layers decoded as they arrive at the decoder, while one encoded using RLCP mode will have increasing resolutions decoded as they arrive, and so on. **signed** If true, then tell the encoder to save the image as signed. Added in version 9.4.0. **cinema_mode** Set the encoder to produce output compliant with the digital cinema specifications. The options here are `"no"` (the default), `"cinema2k-24"` for 24fps 2K, `"cinema2k-48"` for 48fps 2K, and `"cinema4k-24"` for 24fps 4K. Note that for compliant 2K files, _at least one_ of your image dimensions must match 2048 x 1080, while for compliant 4K files, _at least one_ of the dimensions must match 4096 x 2160. **no_jp2** If `True` then don’t wrap the raw codestream in the JP2 file format when saving, otherwise the extension of the filename will be used to determine the format (default). Added in version 9.1.0. **comment** Adds a custom comment to the file, replacing the default “Created by OpenJPEG version” comment. Added in version 9.5.0. **plt** If `True` and OpenJPEG 2.4.0 or later is available, then include a PLT (packet length, tile-part header) marker in the produced file. Defaults to `False`. Added in version 9.5.0. Note To enable JPEG 2000 support, you need to build and install the OpenJPEG library, version 2.0.0 or higher, before building the Python Imaging Library. Windows users can install the OpenJPEG binaries available on the OpenJPEG website, but must add them to their PATH in order to use Pillow (if you fail to do this, you will get errors about not being able to load the `_imaging` DLL). ### MPO¶ Pillow reads and writes Multi Picture Object (MPO) files. When first opened, it loads the primary image. The [`seek()`](../reference/Image.html#PIL.Image.Image.seek "PIL.Image.Image.seek") and [`tell()`](../reference/Image.html#PIL.Image.Image.tell "PIL.Image.Image.tell") methods may be used to read other pictures from the file. The pictures are zero-indexed and random access is supported. #### Saving¶ When calling [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") to write an MPO file, by default only the first frame of a multiframe image will be saved. If the `save_all` argument is present and true, or if `append_images` is not empty, all frames will be saved. **append_images** A list of images to append as additional pictures. Each of the images in the list can be single or multiframe images. Added in version 9.3.0. ### MSP¶ Pillow identifies and reads MSP files from Windows 1 and 2. The library writes uncompressed (Windows 1) versions of this format. ### PCX¶ Pillow reads and writes PCX files containing `1`, `L`, `P`, or `RGB` data. ### PFM¶ Added in version 10.3.0. Pillow reads and writes grayscale (Pf format) Portable FloatMap (PFM) files containing `F` data. Color (PF format) PFM files are not supported. #### Opening¶ The [`open()`](../reference/Image.html#PIL.Image.open "PIL.Image.open") function sets the following [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") properties: **scale** The absolute value of the number stored in the _Scale Factor / Endianness_ line. ### PNG¶ Pillow identifies, reads, and writes PNG files containing `1`, `L`, `LA`, `I`, `P`, `RGB` or `RGBA` data. Interlaced files are supported as of v1.1.7. As of Pillow 6.0, EXIF data can be read from PNG images. However, unlike other image formats, EXIF data is not guaranteed to be present in [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") until [`load()`](../reference/Image.html#PIL.Image.Image.load "PIL.Image.Image.load") has been called. By default Pillow doesn’t allow loading of truncated PNG files, set [`ImageFile.LOAD_TRUNCATED_IMAGES`](../reference/ImageFile.html#PIL.ImageFile.LOAD_TRUNCATED_IMAGES "PIL.ImageFile.LOAD_TRUNCATED_IMAGES") to override this. #### Opening¶ The [`open()`](../reference/Image.html#PIL.Image.open "PIL.Image.open") function sets the following [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") properties, when appropriate: **chromaticity** The chromaticity points, as an 8 tuple of floats. (`White Point X`, `White Point Y`, `Red X`, `Red Y`, `Green X`, `Green Y`, `Blue X`, `Blue Y`) **gamma** Gamma, given as a floating point number. **srgb** The sRGB rendering intent as an integer. > * 0 Perceptual > > * 1 Relative Colorimetric > > * 2 Saturation > > * 3 Absolute Colorimetric > > **transparency** For `P` images: Either the palette index for full transparent pixels, or a byte string with alpha values for each palette entry. For `1`, `L`, `I` and `RGB` images, the color that represents full transparent pixels in this image. This key is omitted if the image is not a transparent palette image. `open` also sets `Image.text` to a dictionary of the values of the `tEXt`, `zTXt`, and `iTXt` chunks of the PNG image. Individual compressed chunks are limited to a decompressed size of [`PngImagePlugin.MAX_TEXT_CHUNK`](../reference/plugins.html#PIL.PngImagePlugin.MAX_TEXT_CHUNK "PIL.PngImagePlugin.MAX_TEXT_CHUNK"), by default 1MB, to prevent decompression bombs. Additionally, the total size of all of the text chunks is limited to [`PngImagePlugin.MAX_TEXT_MEMORY`](../reference/plugins.html#PIL.PngImagePlugin.MAX_TEXT_MEMORY "PIL.PngImagePlugin.MAX_TEXT_MEMORY"), defaulting to 64MB. #### Saving¶ The [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") method supports the following options: **optimize** If present and true, instructs the PNG writer to make the output file as small as possible. This includes extra processing in order to find optimal encoder settings. **transparency** For `P`, `1`, `L`, `I`, and `RGB` images, this option controls what color from the image to mark as transparent. For `P` images, this can be a either the palette index, or a byte string with alpha values for each palette entry. **dpi** A tuple of two numbers corresponding to the desired dpi in each direction. **pnginfo** A [`PIL.PngImagePlugin.PngInfo`](../PIL.html#PIL.PngImagePlugin.PngInfo "PIL.PngImagePlugin.PngInfo") instance containing chunks. **compress_level** ZLIB compression level, a number between 0 and 9: 1 gives best speed, 9 gives best compression, 0 gives no compression at all. Default is 6. When `optimize` option is True `compress_level` has no effect (it is set to 9 regardless of a value passed). **icc_profile** The ICC Profile to include in the saved file. **exif** The exif data to include in the saved file. Added in version 6.0.0. **bits (experimental)** For `P` images, this option controls how many bits to store. If omitted, the PNG writer uses 8 bits (256 colors). **dictionary (experimental)** Set the ZLIB encoder dictionary. Note To enable PNG support, you need to build and install the ZLIB compression library before building the Python Imaging Library. See the [installation documentation](../installation.html) for details. #### APNG sequences¶ The PNG loader includes limited support for reading and writing Animated Portable Network Graphics (APNG) files. When an APNG file is loaded, [`get_format_mimetype()`](../reference/ImageFile.html#PIL.ImageFile.ImageFile.get_format_mimetype "PIL.ImageFile.ImageFile.get_format_mimetype") will return `"image/apng"`. The value of the [`is_animated`](../reference/Image.html#PIL.Image.Image.is_animated "PIL.Image.Image.is_animated") property will be `True` when the [`n_frames`](../reference/Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") property is greater than 1. For APNG files, the `n_frames` property depends on both the animation frame count as well as the presence or absence of a default image. See the `default_image` property documentation below for more details. The [`seek()`](../reference/Image.html#PIL.Image.Image.seek "PIL.Image.Image.seek") and [`tell()`](../reference/Image.html#PIL.Image.Image.tell "PIL.Image.Image.tell") methods are supported. `im.seek()` raises an [`EOFError`](https://docs.python.org/3/library/exceptions.html#EOFError "\(in Python v3.14\)") if you try to seek after the last frame. These [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") properties will be set for APNG frames, where applicable: **default_image** Specifies whether or not this APNG file contains a separate default image, which is not a part of the actual APNG animation. When an APNG file contains a default image, the initially loaded image (i.e. the result of `seek(0)`) will be the default image. To account for the presence of the default image, the [`n_frames`](../reference/Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") property will be set to `frame_count + 1`, where `frame_count` is the actual APNG animation frame count. To load the first APNG animation frame, `seek(1)` must be called. * `True` \- The APNG contains default image, which is not an animation frame. * `False` \- The APNG does not contain a default image. The `n_frames` property will be set to the actual APNG animation frame count. The initially loaded image (i.e. `seek(0)`) will be the first APNG animation frame. **loop** The number of times to loop this APNG, 0 indicates infinite looping. **duration** The time to display this APNG frame (in milliseconds). Note The APNG loader returns images the same size as the APNG file’s logical screen size. The returned image contains the pixel data for a given frame, after applying any APNG frame disposal and frame blend operations (i.e. it contains what a web browser would render for this frame - the composite of all previous frames and this frame). Any APNG file containing sequence errors is treated as an invalid image. The APNG loader will not attempt to repair and reorder files containing sequence errors. #### Saving¶ When calling [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save"), by default only a single frame PNG file will be saved. To save an APNG file (including a single frame APNG), the `save_all` parameter should be set to `True` or `append_images` should not be empty. The following parameters can also be set: **default_image** Boolean value, specifying whether or not the base image is a default image. If `True`, the base image will be used as the default image, and the first image from the `append_images` sequence will be the first APNG animation frame. If `False`, the base image will be used as the first APNG animation frame. Defaults to `False`. **append_images** A list or tuple of images to append as additional frames. Each of the images in the list can be single or multiframe images. The size of each frame should match the size of the base image. Also note that if a frame’s mode does not match that of the base image, the frame will be converted to the base image mode. **loop** Integer number of times to loop this APNG, 0 indicates infinite looping. Defaults to 0. **duration** Integer (or list or tuple of integers) length of time to display this APNG frame (in milliseconds). Defaults to 0. **disposal** An integer (or list or tuple of integers) specifying the APNG disposal operation to be used for this frame before rendering the next frame. Defaults to 0. * 0 ([`OP_NONE`](../reference/plugins.html#PIL.PngImagePlugin.Disposal.OP_NONE "PIL.PngImagePlugin.Disposal.OP_NONE"), default) - No disposal is done on this frame before rendering the next frame. * 1 ([`PIL.PngImagePlugin.Disposal.OP_BACKGROUND`](../reference/plugins.html#PIL.PngImagePlugin.Disposal.OP_BACKGROUND "PIL.PngImagePlugin.Disposal.OP_BACKGROUND")) - This frame’s modified region is cleared to fully transparent black before rendering the next frame. * 2 ([`OP_PREVIOUS`](../reference/plugins.html#PIL.PngImagePlugin.Disposal.OP_PREVIOUS "PIL.PngImagePlugin.Disposal.OP_PREVIOUS")) - This frame’s modified region is reverted to the previous frame’s contents before rendering the next frame. **blend** An integer (or list or tuple of integers) specifying the APNG blend operation to be used for this frame before rendering the next frame. Defaults to 0. * 0 ([`OP_SOURCE`](../reference/plugins.html#PIL.PngImagePlugin.Blend.OP_SOURCE "PIL.PngImagePlugin.Blend.OP_SOURCE")) - All color components of this frame, including alpha, overwrite the previous output image contents. * 1 ([`OP_OVER`](../reference/plugins.html#PIL.PngImagePlugin.Blend.OP_OVER "PIL.PngImagePlugin.Blend.OP_OVER")) - This frame should be alpha composited with the previous output image contents. Note The `duration`, `disposal` and `blend` parameters can be set to lists or tuples to specify values for each individual frame in the animation. The length of the list or tuple must be identical to the total number of actual frames in the APNG animation. If the APNG contains a default image (i.e. `default_image` is set to `True`), these list or tuple parameters should not include an entry for the default image. ### PPM¶ Pillow reads and writes PBM, PGM, PPM and PNM files containing `1`, `L`, `I` or `RGB` data. “Raw” (P4 to P6) formats can be read, and are used when writing. Since Pillow 9.2.0, “plain” (P1 to P3) formats can be read as well. ### QOI¶ Added in version 9.5.0. Pillow reads and writes images in Quite OK Image format using a Python codec. If you wish to write code specifically for this format, [qoi](https://pypi.org/project/qoi/) is an alternative library that uses C to decode the image and interfaces with NumPy. #### Saving¶ The [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") method can take the following keyword arguments: **colorspace** If set to “sRGB”, the colorspace will be written as sRGB with linear alpha, instead of all channels being linear. ### SGI¶ Pillow reads and writes uncompressed `L`, `RGB`, and `RGBA` files. ### SPIDER¶ Pillow reads and writes SPIDER image files of 32-bit floating point data (“F;32F”). Pillow also reads SPIDER stack files containing sequences of SPIDER images. The [`seek()`](../reference/Image.html#PIL.Image.Image.seek "PIL.Image.Image.seek") and [`tell()`](../reference/Image.html#PIL.Image.Image.tell "PIL.Image.Image.tell") methods are supported, and random access is allowed. #### Opening¶ The [`open()`](../reference/Image.html#PIL.Image.open "PIL.Image.open") method sets the following attributes: **format** Set to `SPIDER` **istack** Set to 1 if the file is an image stack, else 0. **n_frames** Set to the number of images in the stack. A convenience method, [`convert2byte()`](../reference/plugins.html#PIL.SpiderImagePlugin.SpiderImageFile.convert2byte "PIL.SpiderImagePlugin.SpiderImageFile.convert2byte"), is provided for converting floating point data to byte data (mode `L`): im = Image.open("image001.spi").convert2byte() #### Saving¶ The extension of SPIDER files may be any 3 alphanumeric characters. Therefore the output format must be specified explicitly: im.save('newimage.spi', format='SPIDER') For more information about the SPIDER image processing package, see ### TGA¶ Pillow reads and writes TGA images containing `L`, `LA`, `P`, `RGB`, and `RGBA` data. Pillow can read and write both uncompressed and run-length encoded TGAs. #### Saving¶ The [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") method can take the following keyword arguments: **compression** If set to “tga_rle”, the file will be run-length encoded. Added in version 5.3.0. **id_section** The identification field. Added in version 5.3.0. **orientation** If present and a positive number, the first pixel is for the top left corner, rather than the bottom left corner. Added in version 5.3.0. ### TIFF¶ Pillow reads and writes TIFF files. It can read both striped and tiled images, pixel and plane interleaved multi-band images. If you have libtiff and its headers installed, Pillow can read and write many kinds of compressed TIFF files. If not, Pillow will only read and write uncompressed files. Note Beginning in version 5.0.0, Pillow requires libtiff to read or write compressed files. Prior to that release, Pillow had buggy support for reading Packbits, LZW and JPEG compressed TIFFs without using libtiff. #### Opening¶ The [`open()`](../reference/Image.html#PIL.Image.open "PIL.Image.open") method sets the following [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") properties: **compression** Compression mode. Added in version 2.0.0. **dpi** Image resolution as an `(xdpi, ydpi)` tuple, where applicable. You can use the [`tag`](../reference/plugins.html#PIL.TiffImagePlugin.TiffImageFile.tag "PIL.TiffImagePlugin.TiffImageFile.tag") attribute to get more detailed information about the image resolution. Added in version 1.1.5. **resolution** Image resolution as an `(xres, yres)` tuple, where applicable. This is a measurement in whichever unit is specified by the file. Added in version 1.1.5. The [`tag_v2`](../reference/plugins.html#PIL.TiffImagePlugin.TiffImageFile.tag_v2 "PIL.TiffImagePlugin.TiffImageFile.tag_v2") attribute contains a dictionary of TIFF metadata. The keys are numerical indexes from [`TiffTags.TAGS_V2`](../reference/TiffTags.html#PIL.TiffTags.PIL.TiffTags.TAGS_V2 "PIL.TiffTags.PIL.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 [`IFDRational`](../reference/plugins.html#PIL.TiffImagePlugin.IFDRational "PIL.TiffImagePlugin.IFDRational") object. > Added in version 3.0.0. For compatibility with legacy code, the [`tag`](../reference/plugins.html#PIL.TiffImagePlugin.TiffImageFile.tag "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)`. > Deprecated since version 3.0.0. #### Reading multi-frame TIFF images¶ The TIFF loader supports the [`seek()`](../reference/Image.html#PIL.Image.Image.seek "PIL.Image.Image.seek") and [`tell()`](../reference/Image.html#PIL.Image.Image.tell "PIL.Image.Image.tell") methods, taking and returning frame numbers within the image file. You can combine these methods to seek to the next frame (`im.seek(im.tell() + 1)`). Frames are numbered from 0 to `im.n_frames - 1`, and can be accessed in any order. `im.seek()` raises an [`EOFError`](https://docs.python.org/3/library/exceptions.html#EOFError "\(in Python v3.14\)") if you try to seek after the last frame. #### Saving¶ The [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") method can take the following keyword arguments: **save_all** If true, or if `append_images` is not empty, Pillow will save all frames of the image to a multiframe tiff document. Added in version 3.4.0. **append_images** A list of images to append as additional frames. Each of the images in the list can be single or multiframe images. Added in version 4.2.0. **tiffinfo** A [`ImageFileDirectory_v2`](../reference/plugins.html#PIL.TiffImagePlugin.ImageFileDirectory_v2 "PIL.TiffImagePlugin.ImageFileDirectory_v2") object or dict object containing tiff tags and values. The TIFF field type is autodetected for Numeric and string values, any other types require using an [`ImageFileDirectory_v2`](../reference/plugins.html#PIL.TiffImagePlugin.ImageFileDirectory_v2 "PIL.TiffImagePlugin.ImageFileDirectory_v2") object and setting the type in [`tagtype`](../reference/plugins.html#PIL.TiffImagePlugin.ImageFileDirectory_v2.tagtype "PIL.TiffImagePlugin.ImageFileDirectory_v2.tagtype") with the appropriate numerical value from [`TiffTags.TYPES`](../reference/TiffTags.html#PIL.TiffTags.PIL.TiffTags.TYPES "PIL.TiffTags.PIL.TiffTags.TYPES"). Added in version 2.3.0. Metadata values that are of the rational type should be passed in using a [`IFDRational`](../reference/plugins.html#PIL.TiffImagePlugin.IFDRational "PIL.TiffImagePlugin.IFDRational") object. Added in version 3.1.0. For compatibility with legacy code, a [`ImageFileDirectory_v1`](../reference/plugins.html#PIL.TiffImagePlugin.ImageFileDirectory_v1 "PIL.TiffImagePlugin.ImageFileDirectory_v1") object may be passed in this field. However, this is deprecated. Added in version 5.4.0. Previous versions only supported some tags when writing using libtiff. The supported list is found in [`TiffTags.LIBTIFF_CORE`](../reference/TiffTags.html#PIL.TiffTags.PIL.TiffTags.LIBTIFF_CORE "PIL.TiffTags.PIL.TiffTags.LIBTIFF_CORE"). Added in version 6.1.0. Added support for signed types (e.g. `TIFF_SIGNED_LONG`) and multiple values. Multiple values for a single tag must be to [`ImageFileDirectory_v2`](../reference/plugins.html#PIL.TiffImagePlugin.ImageFileDirectory_v2 "PIL.TiffImagePlugin.ImageFileDirectory_v2") as a tuple and require a matching type in [`tagtype`](../reference/plugins.html#PIL.TiffImagePlugin.ImageFileDirectory_v2.tagtype "PIL.TiffImagePlugin.ImageFileDirectory_v2.tagtype") tagtype. **exif** Alternate keyword to “tiffinfo”, for consistency with other formats. Added in version 8.4.0. **big_tiff** If true, the image will be saved as a BigTIFF. Added in version 11.1.0. **compression** A string containing the desired compression method for the file. (valid only with libtiff installed) Valid compression methods are: [`None`](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)"), `"group3"`, `"group4"`, `"jpeg"`, `"lzma"`, `"packbits"`, `"tiff_adobe_deflate"`, `"tiff_ccitt"`, `"tiff_lzw"`, `"tiff_raw_16"`, `"tiff_sgilog"`, `"tiff_sgilog24"`, `"tiff_thunderscan"`, `"webp"`, `"zstd"` **quality** The image quality for JPEG compression, on a scale from 0 (worst) to 100 (best). The default is 75. Added in version 6.1.0. These arguments to set the tiff header fields are an alternative to using the general tags available through tiffinfo. **description** **software** **date_time** **artist** **copyright** Strings **icc_profile** The ICC Profile to include in the saved file. **resolution_unit** An integer. 1 for no unit, 2 for inches and 3 for centimeters. **resolution** Either an integer or a float, used for both the x and y resolution. **x_resolution** Either an integer or a float. **y_resolution** Either an integer or a float. **dpi** A tuple of `(x_resolution, y_resolution)`, with inches as the resolution unit. For consistency with other image formats, the x and y resolutions of the dpi will be rounded to the nearest integer. ### WebP¶ Pillow reads and writes WebP files. Requires libwebp v0.5.0 or later. #### Saving¶ The [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") method supports the following options: **lossless** If present and true, instructs the WebP writer to use lossless compression. **quality** Integer, 0-100, defaults to 80. For lossy, 0 gives the smallest size and 100 the largest. For lossless, this parameter is the amount of effort put into the compression: 0 is the fastest, but gives larger files compared to the slowest, but best, 100. **alpha_quality** Integer, 0-100, defaults to 100. For lossy compression only. 0 gives the smallest size and 100 is lossless. **method** Quality/speed trade-off (0=fast, 6=slower-better). Defaults to 4. **exact** If true, preserve the transparent RGB values. Otherwise, discard invisible RGB values for better compression. Defaults to false. **icc_profile** The ICC Profile to include in the saved file. **exif** The exif data to include in the saved file. **xmp** The XMP data to include in the saved file. #### Saving sequences¶ When calling [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") to write a WebP file, by default only the first frame of a multiframe image will be saved. If the `save_all` argument is present and true, or if `append_images` is not empty, all frames will be saved, and the following options will also be available. **append_images** A list of images to append as additional frames. Each of the images in the list can be single or multiframe images. **duration** The display duration of each frame, in milliseconds. Pass a single integer for a constant duration, or a list or tuple to set the duration for each frame separately. **loop** Number of times to repeat the animation. Defaults to [0 = infinite]. **background** Background color of the canvas, as an RGBA tuple with values in the range of (0-255). **minimize_size** If true, minimize the output size (slow). Implicitly disables key-frame insertion. **kmin, kmax** Minimum and maximum distance between consecutive key frames in the output. The library may insert some key frames as needed to satisfy this criteria. Note that these conditions should hold: kmax > kmin and kmin >= kmax / 2 + 1. Also, if kmax <= 0, then key-frame insertion is disabled; and if kmax == 1, then all frames will be key-frames (kmin value does not matter for these special cases). **allow_mixed** If true, use mixed compression mode; the encoder heuristically chooses between lossy and lossless for each frame. ### XBM¶ Pillow reads and writes X bitmap files (mode `1`). ## Read-only formats¶ ### CUR¶ CUR is used to store cursors on Windows. The CUR decoder reads the largest available cursor. Animated cursors are not supported. ### DCX¶ DCX is a container file format for PCX files, defined by Intel. The DCX format is commonly used in fax applications. The DCX decoder can read files containing `1`, `L`, `P`, or `RGB` data. When the file is opened, only the first image is read. You can use [`seek()`](../reference/Image.html#PIL.Image.Image.seek "PIL.Image.Image.seek") or [`ImageSequence`](../reference/ImageSequence.html#module-PIL.ImageSequence "PIL.ImageSequence") to read other images. ### FITS¶ Added in version 9.1.0. Pillow identifies and reads FITS files, commonly used for astronomy. Uncompressed and GZIP_1 compressed images can be read. ### FLI, FLC¶ Pillow reads Autodesk FLI and FLC animations. The [`open()`](../reference/Image.html#PIL.Image.open "PIL.Image.open") method sets the following [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") properties: **duration** The delay (in milliseconds) between each frame. ### FPX¶ Pillow reads Kodak FlashPix files. Only the highest resolution image is read from the file, and the viewing transform is not taken into account. To enable FPX support, you must install [olefile](https://pypi.org/project/olefile/). Note To enable full FlashPix support, you need to build and install the IJG JPEG library before building the Python Imaging Library. See the distribution README for details. ### FTEX¶ Added in version 3.2.0. The FTEX decoder reads textures used for 3D objects in Independence War 2: Edge Of Chaos. The plugin reads a single texture per file, in the compressed and uncompressed formats. ### GBR¶ The GBR decoder reads GIMP brush files, version 1 and 2. #### Opening¶ The [`open()`](../reference/Image.html#PIL.Image.open "PIL.Image.open") method sets the following [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") properties: **comment** The brush name. **spacing** The spacing between the brushes, in pixels. Version 2 only. ### GD¶ Pillow reads uncompressed GD2 files. Note that you must use [`PIL.GdImageFile.open()`](../PIL.html#PIL.GdImageFile.open "PIL.GdImageFile.open") to read such a file. #### Opening¶ The [`open()`](../reference/Image.html#PIL.Image.open "PIL.Image.open") method sets the following [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") properties: **transparency** Transparency color index. This key is omitted if the image is not transparent. ### IMT¶ Pillow reads Image Tools images containing `L` data. ### IPTC/NAA¶ Pillow provides limited read support for IPTC/NAA newsphoto files. ### MCIDAS¶ Pillow identifies and reads 8-bit McIdas area files. ### MIC¶ Pillow identifies and reads Microsoft Image Composer (MIC) files. When opened, the first sprite in the file is loaded. You can use [`seek()`](../reference/Image.html#PIL.Image.Image.seek "PIL.Image.Image.seek") and [`tell()`](../reference/Image.html#PIL.Image.Image.tell "PIL.Image.Image.tell") to read other sprites from the file. Note that there may be an embedded gamma of 2.2 in MIC files. To enable MIC support, you must install [olefile](https://pypi.org/project/olefile/). ### PCD¶ Pillow reads PhotoCD files containing `RGB` data. This only reads the 768x512 resolution image from the file. Higher resolutions are encoded in a proprietary encoding. ### PIXAR¶ Pillow provides limited support for PIXAR raster files. The library can identify and read “dumped” RGB files. The format code is `PIXAR`. ### PSD¶ Pillow identifies and reads PSD files written by Adobe Photoshop 2.5 and 3.0. ### SUN¶ Pillow identifies and reads Sun raster files. ### WAL¶ Added in version 1.1.4. Pillow reads Quake2 WAL texture files. Note that this file format cannot be automatically identified, so you must use the open function in the [`WalImageFile`](../PIL.html#module-PIL.WalImageFile "PIL.WalImageFile") module to read files in this format. By default, a Quake2 standard palette is attached to the texture. To override the palette, use the [`PIL.Image.Image.putpalette()`](../reference/Image.html#PIL.Image.Image.putpalette "PIL.Image.Image.putpalette") method. ### WMF, EMF¶ Pillow can identify WMF and EMF files. On Windows, it can read WMF and EMF files. By default, it will load the image at 72 dpi. To load it at another resolution: from PIL import Image with Image.open("drawing.wmf") as im: im.load(dpi=144) To add other read or write support, use [`PIL.WmfImagePlugin.register_handler()`](../reference/plugins.html#PIL.WmfImagePlugin.register_handler "PIL.WmfImagePlugin.register_handler") to register a WMF and EMF handler. from typing import IO from PIL import Image, ImageFile from PIL import WmfImagePlugin class WmfHandler(ImageFile.StubHandler): def open(self, im: ImageFile.StubImageFile) -> None: ... def load(self, im: ImageFile.StubImageFile) -> Image.Image: ... return image def save(self, im: Image.Image, fp: IO[bytes], filename: str) -> None: ... wmf_handler = WmfHandler() WmfImagePlugin.register_handler(wmf_handler) im = Image.open("sample.wmf") ### XPM¶ Pillow reads X pixmap files as P mode images if there are 256 colors or less, and as RGB images otherwise. #### Opening¶ The [`open()`](../reference/Image.html#PIL.Image.open "PIL.Image.open") method sets the following [`info`](../reference/Image.html#PIL.Image.Image.info "PIL.Image.Image.info") properties: **transparency** Transparency color index. This key is omitted if the image is not transparent. ### XV thumbnails¶ Pillow can read XV thumbnail files. ## Write-only formats¶ ### PALM¶ Pillow provides write-only support for PALM pixmap files. The format code is `Palm`, the extension is `.palm`. ### PDF¶ Pillow can write PDF (Acrobat) images. Such images are written as binary PDF 1.4 files. Different encoding methods are used, depending on the image mode. * 1 mode images are saved using TIFF encoding, or JPEG encoding if libtiff support is unavailable * L, RGB and CMYK mode images use JPEG encoding * P mode images use HEX encoding * LA and RGBA mode images use JPEG2000 encoding #### Saving¶ The [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") method can take the following keyword arguments: **save_all** If a multiframe image is used, by default, only the first image will be saved. To save all frames, each frame to a separate page of the PDF, the `save_all` parameter should be present and set to `True` or `append_images` should not be empty. Added in version 3.0.0. **append_images** A list of [`PIL.Image.Image`](../reference/Image.html#PIL.Image.Image "PIL.Image.Image") objects to append as additional pages. Each of the images in the list can be single or multiframe images. Added in version 4.2.0. **append** Set to True to append pages to an existing PDF file. If the file doesn’t exist, an [`OSError`](https://docs.python.org/3/library/exceptions.html#OSError "\(in Python v3.14\)") will be raised. Added in version 5.1.0. **resolution** Image resolution in DPI. This, together with the number of pixels in the image, will determine the physical dimensions of the page that will be saved in the PDF. **dpi** A tuple of `(x_resolution, y_resolution)`, with inches as the resolution unit. If both the `resolution` parameter and the `dpi` parameter are present, `resolution` will be ignored. **title** The document’s title. If not appending to an existing PDF file, this will default to the filename. Added in version 5.1.0. **author** The name of the person who created the document. Added in version 5.1.0. **subject** The subject of the document. Added in version 5.1.0. **keywords** Keywords associated with the document. Added in version 5.1.0. **creator** If the document was converted to PDF from another format, the name of the conforming product that created the original document from which it was converted. Added in version 5.1.0. **producer** If the document was converted to PDF from another format, the name of the conforming product that converted it to PDF. Added in version 5.1.0. **creationDate** The creation date of the document. If not appending to an existing PDF file, this will default to the current time. Added in version 5.3.0. **modDate** The modification date of the document. If not appending to an existing PDF file, this will default to the current time. Added in version 5.3.0. ## Identify-only formats¶ ### BUFR¶ Added in version 1.1.3. Pillow provides a stub driver for BUFR files. To add read or write support to your application, use [`PIL.BufrStubImagePlugin.register_handler()`](../reference/plugins.html#PIL.BufrStubImagePlugin.register_handler "PIL.BufrStubImagePlugin.register_handler"). ### GRIB¶ Added in version 1.1.5. Pillow provides a stub driver for GRIB files. The driver requires the file to start with a GRIB header. If you have files with embedded GRIB data, or files with multiple GRIB fields, your application has to seek to the header before passing the file handle to Pillow. To add read or write support to your application, use [`PIL.GribStubImagePlugin.register_handler()`](../reference/plugins.html#PIL.GribStubImagePlugin.register_handler "PIL.GribStubImagePlugin.register_handler"). ### HDF5¶ Added in version 1.1.5. Pillow provides a stub driver for HDF5 files. To add read or write support to your application, use [`PIL.Hdf5StubImagePlugin.register_handler()`](../reference/plugins.html#PIL.Hdf5StubImagePlugin.register_handler "PIL.Hdf5StubImagePlugin.register_handler"). ### MPEG¶ Pillow identifies MPEG files. [ Next Text anchors ](text-anchors.html) [ Previous Appendices ](appendices.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * Image file formats * Fully supported formats * AVIF * Saving sequences * BLP * Saving * BMP * Opening * DDS * DIB * EPS * Loading * GIF * Opening * Reading sequences * Saving * Reading local images * ICNS * Loading * Saving * ICO * Saving * IM * JPEG * Opening * Saving * JPEG 2000 * Saving * MPO * Saving * MSP * PCX * PFM * Opening * PNG * Opening * Saving * APNG sequences * Saving * PPM * QOI * Saving * SGI * SPIDER * Opening * Saving * TGA * Saving * TIFF * Opening * Reading multi-frame TIFF images * Saving * WebP * Saving * Saving sequences * XBM * Read-only formats * CUR * DCX * FITS * FLI, FLC * FPX * FTEX * GBR * Opening * GD * Opening * IMT * IPTC/NAA * MCIDAS * MIC * PCD * PIXAR * PSD * SUN * WAL * WMF, EMF * XPM * Opening * XV thumbnails * Write-only formats * PALM * PDF * Saving * Identify-only formats * BUFR * GRIB * HDF5 * MPEG --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/handbook/index.html # Path: handbook/index.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * Handbook * [Overview](overview.html) * [Tutorial](tutorial.html) * [Concepts](concepts.html) * [Appendices](appendices.html) * [Image file formats](image-file-formats.html) * [Text anchors](text-anchors.html) * [Third-party plugins](third-party-plugins.html) * [Writing your own image plugin](writing-your-own-image-plugin.html) * [Decoders](writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](../reference/index.html) * [`Image` module](../reference/Image.html) * [`ImageChops` (“channel operations”) module](../reference/ImageChops.html) * [`ImageCms` module](../reference/ImageCms.html) * [`ImageColor` module](../reference/ImageColor.html) * [`ImageDraw` module](../reference/ImageDraw.html) * [`ImageEnhance` module](../reference/ImageEnhance.html) * [`ImageFile` module](../reference/ImageFile.html) * [`ImageFilter` module](../reference/ImageFilter.html) * [`ImageFont` module](../reference/ImageFont.html) * [`ImageGrab` module](../reference/ImageGrab.html) * [`ImageMath` module](../reference/ImageMath.html) * [`ImageMorph` module](../reference/ImageMorph.html) * [`ImageOps` module](../reference/ImageOps.html) * [`ImagePalette` module](../reference/ImagePalette.html) * [`ImagePath` module](../reference/ImagePath.html) * [`ImageQt` module](../reference/ImageQt.html) * [`ImageSequence` module](../reference/ImageSequence.html) * [`ImageShow` module](../reference/ImageShow.html) * [`ImageStat` module](../reference/ImageStat.html) * [`ImageText` module](../reference/ImageText.html) * [`ImageTk` module](../reference/ImageTk.html) * [`ImageTransform` module](../reference/ImageTransform.html) * [`ImageWin` module (Windows-only)](../reference/ImageWin.html) * [`ExifTags` module](../reference/ExifTags.html) * [`TiffTags` module](../reference/TiffTags.html) * [`JpegPresets` module](../reference/JpegPresets.html) * [`PSDraw` module](../reference/PSDraw.html) * [`PixelAccess` class](../reference/PixelAccess.html) * [`features` module](../reference/features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](../reference/plugins.html) * [Internal reference](../reference/internal_design.html) * [File handling in Pillow](../reference/open_files.html) * [Limits](../reference/limits.html) * [Block allocator](../reference/block_allocator.html) * [Internal modules](../reference/internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](../reference/c_extension_debugging.html) * [Arrow support](../reference/arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/handbook/index.rst.txt "View this page") # Handbook¶ * [Overview](overview.html) * [Image archives](overview.html#image-archives) * [Image display](overview.html#image-display) * [Image processing](overview.html#image-processing) * [Tutorial](tutorial.html) * [Using the Image class](tutorial.html#using-the-image-class) * [Reading and writing images](tutorial.html#reading-and-writing-images) * [Cutting, pasting, and merging images](tutorial.html#cutting-pasting-and-merging-images) * [Geometrical transforms](tutorial.html#geometrical-transforms) * [Color transforms](tutorial.html#color-transforms) * [Image enhancement](tutorial.html#image-enhancement) * [Image sequences](tutorial.html#image-sequences) * [PostScript printing](tutorial.html#postscript-printing) * [More on reading images](tutorial.html#more-on-reading-images) * [Controlling the decoder](tutorial.html#controlling-the-decoder) * [Concepts](concepts.html) * [Bands](concepts.html#bands) * [Modes](concepts.html#modes) * [Size](concepts.html#size) * [Coordinate system](concepts.html#coordinate-system) * [Palette](concepts.html#palette) * [Colors](concepts.html#colors) * [Info](concepts.html#info) * [Transparency](concepts.html#transparency) * [Orientation](concepts.html#orientation) * [Filters](concepts.html#filters) * [Appendices](appendices.html) * [Image file formats](image-file-formats.html) * [Text anchors](text-anchors.html) * [Third-party plugins](third-party-plugins.html) * [Writing your own image plugin](writing-your-own-image-plugin.html) * [Decoders](writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) [ Next Overview ](overview.html) [ Previous Building from source ](../installation/building-from-source.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/handbook/overview.html # Path: handbook/overview.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](index.html) * Overview * [Tutorial](tutorial.html) * [Concepts](concepts.html) * [Appendices](appendices.html) * [Image file formats](image-file-formats.html) * [Text anchors](text-anchors.html) * [Third-party plugins](third-party-plugins.html) * [Writing your own image plugin](writing-your-own-image-plugin.html) * [Decoders](writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](../reference/index.html) * [`Image` module](../reference/Image.html) * [`ImageChops` (“channel operations”) module](../reference/ImageChops.html) * [`ImageCms` module](../reference/ImageCms.html) * [`ImageColor` module](../reference/ImageColor.html) * [`ImageDraw` module](../reference/ImageDraw.html) * [`ImageEnhance` module](../reference/ImageEnhance.html) * [`ImageFile` module](../reference/ImageFile.html) * [`ImageFilter` module](../reference/ImageFilter.html) * [`ImageFont` module](../reference/ImageFont.html) * [`ImageGrab` module](../reference/ImageGrab.html) * [`ImageMath` module](../reference/ImageMath.html) * [`ImageMorph` module](../reference/ImageMorph.html) * [`ImageOps` module](../reference/ImageOps.html) * [`ImagePalette` module](../reference/ImagePalette.html) * [`ImagePath` module](../reference/ImagePath.html) * [`ImageQt` module](../reference/ImageQt.html) * [`ImageSequence` module](../reference/ImageSequence.html) * [`ImageShow` module](../reference/ImageShow.html) * [`ImageStat` module](../reference/ImageStat.html) * [`ImageText` module](../reference/ImageText.html) * [`ImageTk` module](../reference/ImageTk.html) * [`ImageTransform` module](../reference/ImageTransform.html) * [`ImageWin` module (Windows-only)](../reference/ImageWin.html) * [`ExifTags` module](../reference/ExifTags.html) * [`TiffTags` module](../reference/TiffTags.html) * [`JpegPresets` module](../reference/JpegPresets.html) * [`PSDraw` module](../reference/PSDraw.html) * [`PixelAccess` class](../reference/PixelAccess.html) * [`features` module](../reference/features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](../reference/plugins.html) * [Internal reference](../reference/internal_design.html) * [File handling in Pillow](../reference/open_files.html) * [Limits](../reference/limits.html) * [Block allocator](../reference/block_allocator.html) * [Internal modules](../reference/internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](../reference/c_extension_debugging.html) * [Arrow support](../reference/arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/handbook/overview.rst.txt "View this page") # Overview¶ The **Python Imaging Library** adds image processing capabilities to your Python interpreter. This library provides extensive file format support, an efficient internal representation, and fairly powerful image processing capabilities. The core image library is designed for fast access to data stored in a few basic pixel formats. It should provide a solid foundation for a general image processing tool. Let’s look at a few possible uses of this library. ## Image archives¶ The Python Imaging Library is ideal for image archival and batch processing applications. You can use the library to create thumbnails, convert between file formats, print images, etc. The current version identifies and reads a large number of formats. Write support is intentionally restricted to the most commonly used interchange and presentation formats. ## Image display¶ The current release includes Tk [`PhotoImage`](../reference/ImageTk.html#PIL.ImageTk.PhotoImage "PIL.ImageTk.PhotoImage") and [`BitmapImage`](../reference/ImageTk.html#PIL.ImageTk.BitmapImage "PIL.ImageTk.BitmapImage") interfaces, as well as a [`Windows DIB interface`](../reference/ImageWin.html#module-PIL.ImageWin "PIL.ImageWin") that can be used with PythonWin and other Windows-based toolkits. Many other GUI toolkits come with some kind of PIL support. For debugging, there’s also a [`show()`](../reference/Image.html#PIL.Image.Image.show "PIL.Image.Image.show") method which saves an image to disk, and calls an external display utility. ## Image processing¶ The library contains basic image processing functionality, including point operations, filtering with a set of built-in convolution kernels, and colour space conversions. The library also supports image resizing, rotation and arbitrary affine transforms. There’s a histogram method allowing you to pull some statistics out of an image. This can be used for automatic contrast enhancement, and for global statistical analysis. [ Next Tutorial ](tutorial.html) [ Previous Handbook ](index.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * Overview * Image archives * Image display * Image processing --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/handbook/text-anchors.html # Path: handbook/text-anchors.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](index.html) * [Overview](overview.html) * [Tutorial](tutorial.html) * [Concepts](concepts.html) * [Appendices](appendices.html) * [Image file formats](image-file-formats.html) * Text anchors * [Third-party plugins](third-party-plugins.html) * [Writing your own image plugin](writing-your-own-image-plugin.html) * [Decoders](writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](../reference/index.html) * [`Image` module](../reference/Image.html) * [`ImageChops` (“channel operations”) module](../reference/ImageChops.html) * [`ImageCms` module](../reference/ImageCms.html) * [`ImageColor` module](../reference/ImageColor.html) * [`ImageDraw` module](../reference/ImageDraw.html) * [`ImageEnhance` module](../reference/ImageEnhance.html) * [`ImageFile` module](../reference/ImageFile.html) * [`ImageFilter` module](../reference/ImageFilter.html) * [`ImageFont` module](../reference/ImageFont.html) * [`ImageGrab` module](../reference/ImageGrab.html) * [`ImageMath` module](../reference/ImageMath.html) * [`ImageMorph` module](../reference/ImageMorph.html) * [`ImageOps` module](../reference/ImageOps.html) * [`ImagePalette` module](../reference/ImagePalette.html) * [`ImagePath` module](../reference/ImagePath.html) * [`ImageQt` module](../reference/ImageQt.html) * [`ImageSequence` module](../reference/ImageSequence.html) * [`ImageShow` module](../reference/ImageShow.html) * [`ImageStat` module](../reference/ImageStat.html) * [`ImageText` module](../reference/ImageText.html) * [`ImageTk` module](../reference/ImageTk.html) * [`ImageTransform` module](../reference/ImageTransform.html) * [`ImageWin` module (Windows-only)](../reference/ImageWin.html) * [`ExifTags` module](../reference/ExifTags.html) * [`TiffTags` module](../reference/TiffTags.html) * [`JpegPresets` module](../reference/JpegPresets.html) * [`PSDraw` module](../reference/PSDraw.html) * [`PixelAccess` class](../reference/PixelAccess.html) * [`features` module](../reference/features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](../reference/plugins.html) * [Internal reference](../reference/internal_design.html) * [File handling in Pillow](../reference/open_files.html) * [Limits](../reference/limits.html) * [Block allocator](../reference/block_allocator.html) * [Internal modules](../reference/internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](../reference/c_extension_debugging.html) * [Arrow support](../reference/arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/handbook/text-anchors.rst.txt "View this page") # Text anchors¶ The `anchor` parameter determines the alignment of drawn text relative to the `xy` parameter. The default alignment is top left, specifically `la` (left- ascender) for horizontal text and `lt` (left-top) for vertical text. This parameter is only supported by OpenType/TrueType fonts. Other fonts may ignore the parameter and use the default (top left) alignment. ## Specifying an anchor¶ An anchor is specified with a two-character string. The first character is the horizontal alignment, the second character is the vertical alignment. For example, the default value of `la` for horizontal text means left-ascender aligned text. When drawing text with [`PIL.ImageDraw.ImageDraw.text()`](../reference/ImageDraw.html#PIL.ImageDraw.ImageDraw.text "PIL.ImageDraw.ImageDraw.text") with a specific anchor, the text will be placed such that the specified anchor point is at the `xy` coordinates. For example, in the following image, the text is `ms` (middle-baseline) aligned, with `xy` at the intersection of the two lines: ![ms \(middle-baseline\) aligned text.](../_images/test_anchor_quick_ms.png) from PIL import Image, ImageDraw, ImageFont font = ImageFont.truetype("Tests/fonts/NotoSans-Regular.ttf", 48) im = Image.new("RGB", (200, 200), "white") d = ImageDraw.Draw(im) d.line(((0, 100), (200, 100)), "gray") d.line(((100, 0), (100, 200)), "gray") d.text((100, 100), "Quick", fill="black", anchor="ms", font=font) ## Quick reference¶ ![Horizontal text](../_images/anchor_horizontal.svg) ![Vertical text](../_images/anchor_vertical.svg) ## Horizontal anchor alignment¶ `l` — left Anchor is to the left of the text. For _horizontal_ text this is the origin of the first glyph, as shown in the [FreeType tutorial](https://freetype.org/freetype2/docs/tutorial/step2.html). `m` — middle Anchor is horizontally centered with the text. For _vertical_ text it is recommended to use `s` (baseline) alignment instead, as it does not change based on the specific glyphs of the given text. `r` — right Anchor is to the right of the text. For _horizontal_ text this is the advanced origin of the last glyph, as shown in the [FreeType tutorial](https://freetype.org/freetype2/docs/tutorial/step2.html). `s` — baseline _(vertical text only)_ Anchor is at the baseline (middle) of the text. The exact alignment depends on the font. For _vertical_ text this is the recommended alignment, as it does not change based on the specific glyphs of the given text (see image for vertical text above). ## Vertical anchor alignment¶ `a` — ascender / top _(horizontal text only)_ Anchor is at the ascender line (top) of the first line of text, as defined by the font. See [Font metrics on Wikipedia](https://en.wikipedia.org/wiki/Typeface#Font_metrics) for more information. `t` — top _(single-line text only)_ Anchor is at the top of the text. For _vertical_ text this is the origin of the first glyph, as shown in the [FreeType tutorial](https://freetype.org/freetype2/docs/tutorial/step2.html). For _horizontal_ text it is recommended to use `a` (ascender) alignment instead, as it does not change based on the specific glyphs of the given text. `m` — middle Anchor is vertically centered with the text. For _horizontal_ text this is the midpoint of the first ascender line and the last descender line. `s` — baseline _(horizontal text only)_ Anchor is at the baseline (bottom) of the first line of text, only descenders extend below the anchor. See [Font metrics on Wikipedia](https://en.wikipedia.org/wiki/Typeface#Font_metrics) for more information. `b` — bottom _(single-line text only)_ Anchor is at the bottom of the text. For _vertical_ text this is the advanced origin of the last glyph, as shown in the [FreeType tutorial](https://freetype.org/freetype2/docs/tutorial/step2.html). For _horizontal_ text it is recommended to use `d` (descender) alignment instead, as it does not change based on the specific glyphs of the given text. `d` — descender / bottom _(horizontal text only)_ Anchor is at the descender line (bottom) of the last line of text, as defined by the font. See [Font metrics on Wikipedia](https://en.wikipedia.org/wiki/Typeface#Font_metrics) for more information. ## Examples¶ The following image shows several examples of anchors for horizontal text. In each section the `xy` parameter was set to the center shown by the intersection of the two lines. ![Text anchor examples](../_images/anchors.webp) [ Next Third-party plugins ](third-party-plugins.html) [ Previous Image file formats ](image-file-formats.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * Text anchors * Specifying an anchor * Quick reference * Horizontal anchor alignment * Vertical anchor alignment * Examples --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/handbook/third-party-plugins.html # Path: handbook/third-party-plugins.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](index.html) * [Overview](overview.html) * [Tutorial](tutorial.html) * [Concepts](concepts.html) * [Appendices](appendices.html) * [Image file formats](image-file-formats.html) * [Text anchors](text-anchors.html) * Third-party plugins * [Writing your own image plugin](writing-your-own-image-plugin.html) * [Decoders](writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](../reference/index.html) * [`Image` module](../reference/Image.html) * [`ImageChops` (“channel operations”) module](../reference/ImageChops.html) * [`ImageCms` module](../reference/ImageCms.html) * [`ImageColor` module](../reference/ImageColor.html) * [`ImageDraw` module](../reference/ImageDraw.html) * [`ImageEnhance` module](../reference/ImageEnhance.html) * [`ImageFile` module](../reference/ImageFile.html) * [`ImageFilter` module](../reference/ImageFilter.html) * [`ImageFont` module](../reference/ImageFont.html) * [`ImageGrab` module](../reference/ImageGrab.html) * [`ImageMath` module](../reference/ImageMath.html) * [`ImageMorph` module](../reference/ImageMorph.html) * [`ImageOps` module](../reference/ImageOps.html) * [`ImagePalette` module](../reference/ImagePalette.html) * [`ImagePath` module](../reference/ImagePath.html) * [`ImageQt` module](../reference/ImageQt.html) * [`ImageSequence` module](../reference/ImageSequence.html) * [`ImageShow` module](../reference/ImageShow.html) * [`ImageStat` module](../reference/ImageStat.html) * [`ImageText` module](../reference/ImageText.html) * [`ImageTk` module](../reference/ImageTk.html) * [`ImageTransform` module](../reference/ImageTransform.html) * [`ImageWin` module (Windows-only)](../reference/ImageWin.html) * [`ExifTags` module](../reference/ExifTags.html) * [`TiffTags` module](../reference/TiffTags.html) * [`JpegPresets` module](../reference/JpegPresets.html) * [`PSDraw` module](../reference/PSDraw.html) * [`PixelAccess` class](../reference/PixelAccess.html) * [`features` module](../reference/features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](../reference/plugins.html) * [Internal reference](../reference/internal_design.html) * [File handling in Pillow](../reference/open_files.html) * [Limits](../reference/limits.html) * [Block allocator](../reference/block_allocator.html) * [Internal modules](../reference/internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](../reference/c_extension_debugging.html) * [Arrow support](../reference/arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/handbook/third-party-plugins.rst.txt "View this page") # Third-party plugins¶ Pillow uses a plugin model which allows users to add their own decoders and encoders to the library, without any changes to the library itself. Here is a list of PyPI projects that offer additional plugins: * [DjvuRleImagePlugin](https://pypi.org/project/DjvuRleImagePlugin/): Plugin for the DjVu RLE image format as defined in the DjVuLibre docs. * [heif-image-plugin](https://pypi.org/project/heif-image-plugin/): Simple HEIF/HEIC images plugin, based on the pyheif library. * [jxlpy](https://pypi.org/project/jxlpy/): Introduces reading and writing support for JPEG XL. * [pillow-heif](https://pypi.org/project/pillow-heif/): Python bindings to libheif for working with HEIF images. * [pillow-jpls](https://pypi.org/project/pillow-jpls/): Plugin for the JPEG-LS codec, based on the Charls JPEG-LS implementation. Python bindings implemented using pybind11. * [pillow-jxl-plugin](https://pypi.org/project/pillow-jxl-plugin/): Plugin for JPEG-XL, using Rust for bindings. * [pillow-mbm](https://pypi.org/project/pillow-mbm/): Adds support for KSP’s proprietary MBM texture format. * [pillow-svg](https://pypi.org/project/pillow-svg/): Implements basic SVG read support. Supports basic paths, shapes, and text. * [raw-pillow-opener](https://pypi.org/project/raw-pillow-opener/): Simple camera raw opener, based on the rawpy library. [ Next Writing your own image plugin ](writing-your-own-image-plugin.html) [ Previous Text anchors ](text-anchors.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/handbook/tutorial.html # Path: handbook/tutorial.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](index.html) * [Overview](overview.html) * Tutorial * [Concepts](concepts.html) * [Appendices](appendices.html) * [Image file formats](image-file-formats.html) * [Text anchors](text-anchors.html) * [Third-party plugins](third-party-plugins.html) * [Writing your own image plugin](writing-your-own-image-plugin.html) * [Decoders](writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](../reference/index.html) * [`Image` module](../reference/Image.html) * [`ImageChops` (“channel operations”) module](../reference/ImageChops.html) * [`ImageCms` module](../reference/ImageCms.html) * [`ImageColor` module](../reference/ImageColor.html) * [`ImageDraw` module](../reference/ImageDraw.html) * [`ImageEnhance` module](../reference/ImageEnhance.html) * [`ImageFile` module](../reference/ImageFile.html) * [`ImageFilter` module](../reference/ImageFilter.html) * [`ImageFont` module](../reference/ImageFont.html) * [`ImageGrab` module](../reference/ImageGrab.html) * [`ImageMath` module](../reference/ImageMath.html) * [`ImageMorph` module](../reference/ImageMorph.html) * [`ImageOps` module](../reference/ImageOps.html) * [`ImagePalette` module](../reference/ImagePalette.html) * [`ImagePath` module](../reference/ImagePath.html) * [`ImageQt` module](../reference/ImageQt.html) * [`ImageSequence` module](../reference/ImageSequence.html) * [`ImageShow` module](../reference/ImageShow.html) * [`ImageStat` module](../reference/ImageStat.html) * [`ImageText` module](../reference/ImageText.html) * [`ImageTk` module](../reference/ImageTk.html) * [`ImageTransform` module](../reference/ImageTransform.html) * [`ImageWin` module (Windows-only)](../reference/ImageWin.html) * [`ExifTags` module](../reference/ExifTags.html) * [`TiffTags` module](../reference/TiffTags.html) * [`JpegPresets` module](../reference/JpegPresets.html) * [`PSDraw` module](../reference/PSDraw.html) * [`PixelAccess` class](../reference/PixelAccess.html) * [`features` module](../reference/features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](../reference/plugins.html) * [Internal reference](../reference/internal_design.html) * [File handling in Pillow](../reference/open_files.html) * [Limits](../reference/limits.html) * [Block allocator](../reference/block_allocator.html) * [Internal modules](../reference/internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](../reference/c_extension_debugging.html) * [Arrow support](../reference/arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/handbook/tutorial.rst.txt "View this page") # Tutorial¶ ## Using the Image class¶ The most important class in the Python Imaging Library is the [`Image`](../reference/Image.html#PIL.Image.Image "PIL.Image.Image") class, defined in the module with the same name. You can create instances of this class in several ways; either by loading images from files, processing other images, or creating images from scratch. To load an image from a file, use the [`open()`](../reference/Image.html#PIL.Image.open "PIL.Image.open") function in the [`Image`](../reference/Image.html#module-PIL.Image "PIL.Image") module: >>> from PIL import Image >>> im = Image.open("hopper.ppm") If successful, this function returns an [`Image`](../reference/Image.html#PIL.Image.Image "PIL.Image.Image") object. You can now use instance attributes to examine the file contents: >>> print(im.format, im.size, im.mode) PPM (512, 512) RGB The [`format`](../reference/Image.html#PIL.Image.Image.format "PIL.Image.Image.format") attribute identifies the source of an image. If the image was not read from a file, it is set to None. The size attribute is a 2-tuple containing width and height (in pixels). The [`mode`](../reference/Image.html#PIL.Image.Image.mode "PIL.Image.Image.mode") attribute defines the number and names of the bands in the image, and also the pixel type and depth. Common modes are “L” (luminance) for grayscale images, “RGB” for true color images, and “CMYK” for pre-press images. If the file cannot be opened, an [`OSError`](https://docs.python.org/3/library/exceptions.html#OSError "\(in Python v3.14\)") exception is raised. Once you have an instance of the [`Image`](../reference/Image.html#PIL.Image.Image "PIL.Image.Image") class, you can use the methods defined by this class to process and manipulate the image. For example, let’s display the image we just loaded: >>> im.show() ![../_images/show_hopper.webp](../_images/show_hopper.webp) Note The standard version of [`show()`](../reference/Image.html#PIL.Image.Image.show "PIL.Image.Image.show") is not very efficient, since it saves the image to a temporary file and calls a utility to display the image. If you don’t have an appropriate utility installed, it won’t even work. When it does work though, it is very handy for debugging and tests. The following sections provide an overview of the different functions provided in this library. ## Reading and writing images¶ The Python Imaging Library supports a wide variety of image file formats. To read files from disk, use the [`open()`](../reference/Image.html#PIL.Image.open "PIL.Image.open") function in the [`Image`](../reference/Image.html#module-PIL.Image "PIL.Image") module. You don’t have to know the file format to open a file. The library automatically determines the format based on the contents of the file. To save a file, use the [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") method of the [`Image`](../reference/Image.html#PIL.Image.Image "PIL.Image.Image") class. When saving files, the name becomes important. Unless you specify the format, the library uses the filename extension to discover which file storage format to use. ### Convert files to JPEG¶ import os, sys from PIL import Image for infile in sys.argv[1:]: f, e = os.path.splitext(infile) outfile = f + ".jpg" if infile != outfile: try: with Image.open(infile) as im: im.save(outfile) except OSError: print("cannot convert", infile) ![../_images/hopper.jpg](../_images/hopper.jpg) A second argument can be supplied to the [`save()`](../reference/Image.html#PIL.Image.Image.save "PIL.Image.Image.save") method which explicitly specifies a file format. If you use a non-standard extension, you must always specify the format this way: ### Create JPEG thumbnails¶ import os, sys from PIL import Image size = (128, 128) for infile in sys.argv[1:]: outfile = os.path.splitext(infile)[0] + ".thumbnail" if infile != outfile: try: with Image.open(infile) as im: im.thumbnail(size) im.save(outfile, "JPEG") except OSError: print("cannot create thumbnail for", infile) ![../_images/thumbnail_hopper.jpg](../_images/thumbnail_hopper.jpg) It is important to note that the library doesn’t decode or load the raster data unless it really has to. When you open a file, the file header is read to determine the file format and extract things like mode, size, and other properties required to decode the file, but the rest of the file is not processed until later. This means that opening an image file is a fast operation, which is independent of the file size and compression type. Here’s a simple script to quickly identify a set of image files: ### Identify image files¶ import sys from PIL import Image for infile in sys.argv[1:]: try: with Image.open(infile) as im: print(infile, im.format, f"{im.size}x{im.mode}") except OSError: pass ## Cutting, pasting, and merging images¶ The [`Image`](../reference/Image.html#PIL.Image.Image "PIL.Image.Image") class contains methods allowing you to manipulate regions within an image. To extract a sub-rectangle from an image, use the [`crop()`](../reference/Image.html#PIL.Image.Image.crop "PIL.Image.Image.crop") method. ### Copying a subrectangle from an image¶ box = (0, 0, 64, 64) region = im.crop(box) The region is defined by a 4-tuple, where coordinates are (left, upper, right, lower). The Python Imaging Library uses a coordinate system with (0, 0) in the upper left corner. Also note that coordinates refer to positions between the pixels, so the region in the above example is exactly 64x64 pixels. The region could now be processed in a certain manner and pasted back. ![../_images/cropped_hopper.webp](../_images/cropped_hopper.webp) ### Processing a subrectangle, and pasting it back¶ region = region.transpose(Image.Transpose.ROTATE_180) im.paste(region, box) When pasting regions back, the size of the region must match the given region exactly. In addition, the region cannot extend outside the image. However, the modes of the original image and the region do not need to match. If they don’t, the region is automatically converted before being pasted (see the section on Color transforms below for details). ![../_images/pasted_hopper.webp](../_images/pasted_hopper.webp) Here’s an additional example: ### Rolling an image¶ def roll(im: Image.Image, delta: int) -> Image.Image: """Roll an image sideways.""" xsize, ysize = im.size delta = delta % xsize if delta == 0: return im part1 = im.crop((0, 0, delta, ysize)) part2 = im.crop((delta, 0, xsize, ysize)) im.paste(part1, (xsize - delta, 0, xsize, ysize)) im.paste(part2, (0, 0, xsize - delta, ysize)) return im ![../_images/rolled_hopper.webp](../_images/rolled_hopper.webp) Or if you would like to merge two images into a wider image: ### Merging images¶ def merge(im1: Image.Image, im2: Image.Image) -> Image.Image: w = im1.size[0] + im2.size[0] h = max(im1.size[1], im2.size[1]) im = Image.new("RGBA", (w, h)) im.paste(im1) im.paste(im2, (im1.size[0], 0)) return im ![../_images/merged_hopper.webp](../_images/merged_hopper.webp) For more advanced tricks, the paste method can also take a transparency mask as an optional argument. In this mask, the value 255 indicates that the pasted image is opaque in that position (that is, the pasted image should be used as is). The value 0 means that the pasted image is completely transparent. Values in-between indicate different levels of transparency. For example, pasting an RGBA image and also using it as the mask would paste the opaque portion of the image but not its transparent background. The Python Imaging Library also allows you to work with the individual bands of an multi-band image, such as an RGB image. The split method creates a set of new images, each containing one band from the original multi-band image. The merge function takes a mode and a tuple of images, and combines them into a new image. The following sample swaps the three bands of an RGB image: ### Splitting and merging bands¶ r, g, b = im.split() im = Image.merge("RGB", (b, g, r)) Note that for a single-band image, [`split()`](../reference/Image.html#PIL.Image.Image.split "PIL.Image.Image.split") returns the image itself. To work with individual color bands, you may want to convert the image to “RGB” first. ![../_images/rebanded_hopper.webp](../_images/rebanded_hopper.webp) ## Geometrical transforms¶ The [`PIL.Image.Image`](../reference/Image.html#PIL.Image.Image "PIL.Image.Image") class contains methods to [`resize()`](../reference/Image.html#PIL.Image.Image.resize "PIL.Image.Image.resize") and [`rotate()`](../reference/Image.html#PIL.Image.Image.rotate "PIL.Image.Image.rotate") an image. The former takes a tuple giving the new size, the latter the angle in degrees counter-clockwise. ### Simple geometry transforms¶ out = im.resize((128, 128)) out = im.rotate(45) # degrees counter-clockwise ![../_images/rotated_hopper_90.webp](../_images/rotated_hopper_90.webp) To rotate the image in 90 degree steps, you can either use the [`rotate()`](../reference/Image.html#PIL.Image.Image.rotate "PIL.Image.Image.rotate") method or the [`transpose()`](../reference/Image.html#PIL.Image.Image.transpose "PIL.Image.Image.transpose") method. The latter can also be used to flip an image around its horizontal or vertical axis. ### Transposing an image¶ out = im.transpose(Image.Transpose.FLIP_LEFT_RIGHT) ![../_images/flip_left_right_hopper.webp](../_images/flip_left_right_hopper.webp) out = im.transpose(Image.Transpose.FLIP_TOP_BOTTOM) ![../_images/flip_top_bottom_hopper.webp](../_images/flip_top_bottom_hopper.webp) out = im.transpose(Image.Transpose.ROTATE_90) ![../_images/rotated_hopper_90.webp](../_images/rotated_hopper_90.webp) out = im.transpose(Image.Transpose.ROTATE_180) ![../_images/rotated_hopper_180.webp](../_images/rotated_hopper_180.webp) out = im.transpose(Image.Transpose.ROTATE_270) ![../_images/rotated_hopper_270.webp](../_images/rotated_hopper_270.webp) `transpose(ROTATE)` operations can also be performed identically with [`rotate()`](../reference/Image.html#PIL.Image.Image.rotate "PIL.Image.Image.rotate") operations, provided the `expand` flag is true, to provide for the same changes to the image’s size. A more general form of image transformations can be carried out via the [`transform()`](../reference/Image.html#PIL.Image.Image.transform "PIL.Image.Image.transform") method. ### Relative resizing¶ Instead of calculating the size of the new image when resizing, you can also choose to resize relative to a given size. from PIL import Image, ImageOps size = (100, 150) with Image.open("hopper.webp") as im: ImageOps.contain(im, size).save("imageops_contain.webp") ImageOps.cover(im, size).save("imageops_cover.webp") ImageOps.fit(im, size).save("imageops_fit.webp") ImageOps.pad(im, size, color="#f00").save("imageops_pad.webp") # thumbnail() can also be used, # but will modify the image object in place im.thumbnail(size) im.save("image_thumbnail.webp") | [`thumbnail()`](../reference/Image.html#PIL.Image.Image.thumbnail "PIL.Image.Image.thumbnail") | [`contain()`](../reference/ImageOps.html#PIL.ImageOps.contain "PIL.ImageOps.contain") | [`cover()`](../reference/ImageOps.html#PIL.ImageOps.cover "PIL.ImageOps.cover") | [`fit()`](../reference/ImageOps.html#PIL.ImageOps.fit "PIL.ImageOps.fit") | [`pad()`](../reference/ImageOps.html#PIL.ImageOps.pad "PIL.ImageOps.pad") ---|---|---|---|---|--- Given size | `(100, 150)` | `(100, 150)` | `(100, 150)` | `(100, 150)` | `(100, 150)` Resulting image | ![../_images/image_thumbnail.webp](../_images/image_thumbnail.webp) | ![../_images/imageops_contain.webp](../_images/imageops_contain.webp) | ![../_images/imageops_cover.webp](../_images/imageops_cover.webp) | ![../_images/imageops_fit.webp](../_images/imageops_fit.webp) | ![../_images/imageops_pad.webp](../_images/imageops_pad.webp) Resulting size | `100×100` | `100×100` | `150×150` | `100×150` | `100×150` ## Color transforms¶ The Python Imaging Library allows you to convert images between different pixel representations using the [`convert()`](../reference/Image.html#PIL.Image.Image.convert "PIL.Image.Image.convert") method. ### Converting between modes¶ from PIL import Image with Image.open("hopper.ppm") as im: im = im.convert("L") The library supports transformations between each supported mode and the “L” and “RGB” modes. To convert between other modes, you may have to use an intermediate image (typically an “RGB” image). ## Image enhancement¶ The Python Imaging Library provides a number of methods and modules that can be used to enhance images. ### Filters¶ The [`ImageFilter`](../reference/ImageFilter.html#module-PIL.ImageFilter "PIL.ImageFilter") module contains a number of pre-defined enhancement filters that can be used with the [`filter()`](../reference/Image.html#PIL.Image.Image.filter "PIL.Image.Image.filter") method. #### Applying filters¶ from PIL import ImageFilter out = im.filter(ImageFilter.DETAIL) ![../_images/enhanced_hopper.webp](../_images/enhanced_hopper.webp) ### Point operations¶ The [`point()`](../reference/Image.html#PIL.Image.Image.point "PIL.Image.Image.point") method can be used to translate the pixel values of an image (e.g. image contrast manipulation). In most cases, a function object expecting one argument can be passed to this method. Each pixel is processed according to that function: #### Applying point transforms¶ # multiply each pixel by 20 out = im.point(lambda i: i * 20) ![../_images/transformed_hopper.webp](../_images/transformed_hopper.webp) Using the above technique, you can quickly apply any simple expression to an image. You can also combine the [`point()`](../reference/Image.html#PIL.Image.Image.point "PIL.Image.Image.point") and [`paste()`](../reference/Image.html#PIL.Image.Image.paste "PIL.Image.Image.paste") methods to selectively modify an image: #### Processing individual bands¶ # split the image into individual bands source = im.split() R, G, B = 0, 1, 2 # select regions where red is less than 100 mask = source[R].point(lambda i: i < 100 and 255) # process the green band out = source[G].point(lambda i: i * 0.7) # paste the processed band back, but only where red was < 100 source[G].paste(out, None, mask) # build a new multiband image im = Image.merge(im.mode, source) Note the syntax used to create the mask: imout = im.point(lambda i: expression and 255) ![../_images/masked_hopper.webp](../_images/masked_hopper.webp) Python only evaluates the portion of a logical expression as is necessary to determine the outcome, and returns the last value examined as the result of the expression. So if the expression above is false (0), Python does not look at the second operand, and thus returns 0. Otherwise, it returns 255. ### Enhancement¶ For more advanced image enhancement, you can use the classes in the [`ImageEnhance`](../reference/ImageEnhance.html#module-PIL.ImageEnhance "PIL.ImageEnhance") module. Once created from an image, an enhancement object can be used to quickly try out different settings. You can adjust contrast, brightness, color balance and sharpness in this way. #### Enhancing images¶ from PIL import ImageEnhance enh = ImageEnhance.Contrast(im) enh.enhance(1.3).show("30% more contrast") ![../_images/contrasted_hopper.jpg](../_images/contrasted_hopper.jpg) ## Image sequences¶ The Python Imaging Library contains some basic support for image sequences (also called animation formats). Supported sequence formats include FLI/FLC, GIF, and a few experimental formats. TIFF files can also contain more than one frame. When you open a sequence file, PIL automatically loads the first frame in the sequence. You can use the seek and tell methods to move between different frames: ### Reading sequences¶ from PIL import Image with Image.open("animation.gif") as im: im.seek(1) # skip to the second frame try: while 1: im.seek(im.tell() + 1) # do something to im except EOFError: pass # end of sequence As seen in this example, you’ll get an [`EOFError`](https://docs.python.org/3/library/exceptions.html#EOFError "\(in Python v3.14\)") exception when the sequence ends. ### Writing sequences¶ You can create animated GIFs with Pillow, e.g. from PIL import Image # List of image filenames image_filenames = [ "hopper.jpg", "rotated_hopper_270.jpg", "rotated_hopper_180.jpg", "rotated_hopper_90.jpg", ] # Open images and create a list images = [Image.open(filename) for filename in image_filenames] # Save the images as an animated GIF images[0].save( "animated_hopper.gif", append_images=images[1:], duration=500, # duration of each frame in milliseconds loop=0, # loop forever ) ![../_images/animated_hopper.gif](../_images/animated_hopper.gif) The following class lets you use the for-statement to loop over the sequence: ### Using the [`Iterator`](../reference/ImageSequence.html#PIL.ImageSequence.Iterator "PIL.ImageSequence.Iterator") class¶ from PIL import ImageSequence for frame in ImageSequence.Iterator(im): # ...do something to frame... ## PostScript printing¶ The Python Imaging Library includes functions to print images, text and graphics on PostScript printers. Here’s a simple example: ### Drawing PostScript¶ from PIL import Image, PSDraw import os # Define the PostScript file ps_file = open("hopper.ps", "wb") # Create a PSDraw object ps = PSDraw.PSDraw(ps_file) # Start the document ps.begin_document() # Set the text to be drawn text = "Hopper" # Define the PostScript font font_name = "Helvetica-Narrow-Bold" font_size = 36 # Calculate text size (approximation as PSDraw doesn't provide direct method) # Assuming average character width as 0.6 of the font size text_width = len(text) * font_size * 0.6 text_height = font_size # Set the position (top-center) page_width, page_height = 595, 842 # A4 size in points text_x = (page_width - text_width) // 2 text_y = page_height - text_height - 50 # Distance from the top of the page # Load the image image_path = "hopper.ppm" # Update this with your image path with Image.open(image_path) as im: # Resize the image if it's too large im.thumbnail((page_width - 100, page_height // 2)) # Define the box where the image will be placed img_x = (page_width - im.width) // 2 img_y = text_y + text_height - 200 # 200 points below the text # Draw the image (75 dpi) ps.image((img_x, img_y, img_x + im.width, img_y + im.height), im, 75) # Draw the text ps.setfont(font_name, font_size) ps.text((text_x, text_y), text) # End the document ps.end_document() ps_file.close() ![../_images/hopper_ps.webp](../_images/hopper_ps.webp) Note PostScript converted to PDF for display purposes ## More on reading images¶ As described earlier, the [`open()`](../reference/Image.html#PIL.Image.open "PIL.Image.open") function of the [`Image`](../reference/Image.html#module- PIL.Image "PIL.Image") module is used to open an image file. In most cases, you simply pass it the filename as an argument. `Image.open()` can be used as a context manager: from PIL import Image with Image.open("hopper.ppm") as im: ... If everything goes well, the result is an [`PIL.Image.Image`](../reference/Image.html#PIL.Image.Image "PIL.Image.Image") object. Otherwise, an [`OSError`](https://docs.python.org/3/library/exceptions.html#OSError "\(in Python v3.14\)") exception is raised. You can use a file-like object instead of the filename. The object must implement `file.read`, `file.seek` and `file.tell` methods, and be opened in binary mode. ### Reading from an open file¶ from PIL import Image with open("hopper.ppm", "rb") as fp: im = Image.open(fp) To read an image from binary data, use the [`BytesIO`](https://docs.python.org/3/library/io.html#io.BytesIO "\(in Python v3.14\)") class: ### Reading from binary data¶ from PIL import Image import io im = Image.open(io.BytesIO(buffer)) Note that the library rewinds the file (using `seek(0)`) before reading the image header. In addition, seek will also be used when the image data is read (by the load method). If the image file is embedded in a larger file, such as a tar file, you can use the [`ContainerIO`](../PIL.html#module-PIL.ContainerIO "PIL.ContainerIO") or [`TarIO`](../PIL.html#module-PIL.TarIO "PIL.TarIO") modules to access it. ### Reading from URL¶ from PIL import Image from urllib.request import urlopen url = "https://python-pillow.github.io/assets/images/pillow-logo.png" img = Image.open(urlopen(url)) ### Reading from a tar archive¶ from PIL import Image, TarIO fp = TarIO.TarIO("hopper.tar", "hopper.jpg") im = Image.open(fp) ### Batch processing¶ Operations can be applied to multiple image files. For example, all PNG images in the current directory can be saved as JPEGs at reduced quality. import glob from PIL import Image def compress_image(source_path: str, dest_path: str) -> None: with Image.open(source_path) as img: if img.mode != "RGB": img = img.convert("RGB") img.save(dest_path, "JPEG", optimize=True, quality=80) paths = glob.glob("*.png") for path in paths: compress_image(path, path[:-4] + ".jpg") Since images can also be opened from a `Path` from the `pathlib` module, the example could be modified to use `pathlib` instead of the `glob` module. from pathlib import Path paths = Path(".").glob("*.png") for path in paths: compress_image(path, path.stem + ".jpg") ## Controlling the decoder¶ Some decoders allow you to manipulate the image while reading it from a file. This can often be used to speed up decoding when creating thumbnails (when speed is usually more important than quality) and printing to a monochrome laser printer (when only a grayscale version of the image is needed). The [`draft()`](../reference/Image.html#PIL.Image.Image.draft "PIL.Image.Image.draft") method manipulates an opened but not yet loaded image so it as closely as possible matches the given mode and size. This is done by reconfiguring the image decoder. ### Reading in draft mode¶ This is only available for JPEG and MPO files. from PIL import Image with Image.open(file) as im: print("original =", im.mode, im.size) im.draft("L", (100, 100)) print("draft =", im.mode, im.size) This prints something like: original = RGB (512, 512) draft = L (128, 128) Note that the resulting image may not exactly match the requested mode and size. To make sure that the image is not larger than the given size, use the thumbnail method instead. [ Next Concepts ](concepts.html) [ Previous Overview ](overview.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * Tutorial * Using the Image class * Reading and writing images * Convert files to JPEG * Create JPEG thumbnails * Identify image files * Cutting, pasting, and merging images * Copying a subrectangle from an image * Processing a subrectangle, and pasting it back * Rolling an image * Merging images * Splitting and merging bands * Geometrical transforms * Simple geometry transforms * Transposing an image * Relative resizing * Color transforms * Converting between modes * Image enhancement * Filters * Applying filters * Point operations * Applying point transforms * Processing individual bands * Enhancement * Enhancing images * Image sequences * Reading sequences * Writing sequences * Using the `Iterator` class * PostScript printing * Drawing PostScript * More on reading images * Reading from an open file * Reading from binary data * Reading from URL * Reading from a tar archive * Batch processing * Controlling the decoder * Reading in draft mode --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/handbook/writing-your-own-image-plugin.html # Path: handbook/writing-your-own-image-plugin.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](index.html) * [Overview](overview.html) * [Tutorial](tutorial.html) * [Concepts](concepts.html) * [Appendices](appendices.html) * [Image file formats](image-file-formats.html) * [Text anchors](text-anchors.html) * [Third-party plugins](third-party-plugins.html) * Writing your own image plugin * Decoders * Writing your own file codec in C * Writing your own file codec in Python * [Reference](../reference/index.html) * [`Image` module](../reference/Image.html) * [`ImageChops` (“channel operations”) module](../reference/ImageChops.html) * [`ImageCms` module](../reference/ImageCms.html) * [`ImageColor` module](../reference/ImageColor.html) * [`ImageDraw` module](../reference/ImageDraw.html) * [`ImageEnhance` module](../reference/ImageEnhance.html) * [`ImageFile` module](../reference/ImageFile.html) * [`ImageFilter` module](../reference/ImageFilter.html) * [`ImageFont` module](../reference/ImageFont.html) * [`ImageGrab` module](../reference/ImageGrab.html) * [`ImageMath` module](../reference/ImageMath.html) * [`ImageMorph` module](../reference/ImageMorph.html) * [`ImageOps` module](../reference/ImageOps.html) * [`ImagePalette` module](../reference/ImagePalette.html) * [`ImagePath` module](../reference/ImagePath.html) * [`ImageQt` module](../reference/ImageQt.html) * [`ImageSequence` module](../reference/ImageSequence.html) * [`ImageShow` module](../reference/ImageShow.html) * [`ImageStat` module](../reference/ImageStat.html) * [`ImageText` module](../reference/ImageText.html) * [`ImageTk` module](../reference/ImageTk.html) * [`ImageTransform` module](../reference/ImageTransform.html) * [`ImageWin` module (Windows-only)](../reference/ImageWin.html) * [`ExifTags` module](../reference/ExifTags.html) * [`TiffTags` module](../reference/TiffTags.html) * [`JpegPresets` module](../reference/JpegPresets.html) * [`PSDraw` module](../reference/PSDraw.html) * [`PixelAccess` class](../reference/PixelAccess.html) * [`features` module](../reference/features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](../reference/plugins.html) * [Internal reference](../reference/internal_design.html) * [File handling in Pillow](../reference/open_files.html) * [Limits](../reference/limits.html) * [Block allocator](../reference/block_allocator.html) * [Internal modules](../reference/internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](../reference/c_extension_debugging.html) * [Arrow support](../reference/arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/handbook/writing-your-own-image-plugin.rst.txt "View this page") # Writing your own image plugin¶ Pillow uses a plugin model which allows you to add your own decoders and encoders to the library, without any changes to the library itself. Such plugins usually have names like `XxxImagePlugin.py`, where `Xxx` is a unique format name (usually an abbreviation). Warning Pillow >= 2.1.0 no longer automatically imports any file in the Python path with a name ending in `ImagePlugin.py`. You will need to import your image plugin manually. Pillow decodes files in two stages: 1. It loops over the available image plugins in the loaded order, and calls the plugin’s `_accept` function with the first 16 bytes of the file. If the `_accept` function returns true, the plugin’s `_open` method is called to set up the image metadata and image tiles. The `_open` method is not for decoding the actual image data. 2. When the image data is requested, the `ImageFile.load` method is called, which sets up a decoder for each tile and feeds the data to it. An image plugin should contain a format handler derived from the [`PIL.ImageFile.ImageFile`](../reference/ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") base class. This class should provide an `_open` method, which reads the file header and set at least the internal `_size` and `_mode` attributes so that [`mode`](../reference/Image.html#PIL.Image.Image.mode "PIL.Image.Image.mode") and [`size`](../reference/Image.html#PIL.Image.Image.size "PIL.Image.Image.size") are populated. To be able to load the file, the method must also create a list of `tile` descriptors, which contain a decoder name, extents of the tile, and any decoder-specific data. The format handler class must be explicitly registered, via a call to the [`Image`](../reference/Image.html#module-PIL.Image "PIL.Image") module. Note For performance reasons, it is important that the `_open` method quickly rejects files that do not have the appropriate contents. ## Example¶ The following plugin supports a simple format, which has a 128-byte header consisting of the words “SPAM” followed by the width, height, and pixel size in bits. The header fields are separated by spaces. The image data follows directly after the header, and can be either bi-level, grayscale, or 24-bit true color. **SpamImagePlugin.py** : from PIL import Image, ImageFile def _accept(prefix: bytes) -> bool: return prefix.startswith(b"SPAM") class SpamImageFile(ImageFile.ImageFile): format = "SPAM" format_description = "Spam raster image" def _open(self) -> None: header = self.fp.read(128).split() # size in pixels (width, height) self._size = int(header[1]), int(header[2]) # mode setting bits = int(header[3]) if bits == 1: self._mode = "1" elif bits == 8: self._mode = "L" elif bits == 24: self._mode = "RGB" else: msg = "unknown number of bits" raise SyntaxError(msg) # data descriptor self.tile = [ImageFile._Tile("raw", (0, 0) + self.size, 128, (self.mode, 0, 1))] Image.register_open(SpamImageFile.format, SpamImageFile, _accept) Image.register_extensions( SpamImageFile.format, [ ".spam", ".spa", # DOS version ], ) The format handler must always set the internal `_size` and `_mode` attributes so that [`size`](../reference/Image.html#PIL.Image.Image.size "PIL.Image.Image.size") and [`mode`](../reference/Image.html#PIL.Image.Image.mode "PIL.Image.Image.mode") are populated. If these are not set, the file cannot be opened. To simplify the plugin, the calling code considers exceptions like [`SyntaxError`](https://docs.python.org/3/library/exceptions.html#SyntaxError "\(in Python v3.14\)"), [`KeyError`](https://docs.python.org/3/library/exceptions.html#KeyError "\(in Python v3.14\)"), [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "\(in Python v3.14\)"), [`EOFError`](https://docs.python.org/3/library/exceptions.html#EOFError "\(in Python v3.14\)") and [`struct.error`](https://docs.python.org/3/library/struct.html#struct.error "\(in Python v3.14\)") as a failure to identify the file. Note that the image plugin must be explicitly registered using [`PIL.Image.register_open()`](../reference/Image.html#PIL.Image.register_open "PIL.Image.register_open"). Although not required, it is also a good idea to register any extensions used by this format. Once the plugin has been imported, it can be used: from PIL import Image import SpamImagePlugin with Image.open("hopper.spam") as im: pass ## The `tile` attribute¶ To be able to read the file as well as just identifying it, the `tile` attribute must also be set. This attribute consists of a list of tile descriptors, where each descriptor specifies how data should be loaded to a given region in the image. In most cases, only a single descriptor is used, covering the full image. [`PsdImagePlugin.PsdImageFile`](../reference/plugins.html#PIL.PsdImagePlugin.PsdImageFile "PIL.PsdImagePlugin.PsdImageFile") uses multiple tiles to combine channels within a single layer, given that the channels are stored separately, one after the other. The tile descriptor is a 4-tuple with the following contents: (decoder, region, offset, parameters) The fields are used as follows: **decoder** Specifies which decoder to use. The `raw` decoder used here supports uncompressed data, in a variety of pixel formats. For more information on this decoder, see the description below. A list of C decoders can be seen under codecs section of the function array in `_imaging.c`. Python decoders are registered within the relevant plugins. **region** A 4-tuple specifying where to store data in the image. **offset** Byte offset from the beginning of the file to image data. **parameters** Parameters to the decoder. The contents of this field depends on the decoder specified by the first field in the tile descriptor tuple. If the decoder doesn’t need any parameters, use [`None`](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") for this field. Note that the `tile` attribute contains a list of tile descriptors, not just a single descriptor. # Decoders¶ ## The raw decoder¶ The `raw` decoder is used to read uncompressed data from an image file. It can be used with most uncompressed file formats, such as PPM, BMP, uncompressed TIFF, and many others. To use the raw decoder with the [`PIL.Image.frombytes()`](../reference/Image.html#PIL.Image.frombytes "PIL.Image.frombytes") function, use the following syntax: image = Image.frombytes( mode, size, data, "raw", raw_mode, stride, orientation ) When used in a tile descriptor, the parameter field should look like: (raw_mode, stride, orientation) The fields are used as follows: **raw_mode** The pixel layout used in the file, and is used to properly convert data to PIL’s internal layout. For a summary of the available formats, see the table below. **stride** The distance in bytes between two consecutive lines in the image. If 0, the image is assumed to be packed (no padding between lines). If omitted, the stride defaults to 0. **orientation** Whether the first line in the image is the top line on the screen (1), or the bottom line (-1). If omitted, the orientation defaults to 1. The **raw mode** field is used to determine how the data should be unpacked to match PIL’s internal pixel layout. PIL supports a large set of raw modes; for a complete list, see the table in the `Unpack.c` module. The following table describes some commonly used **raw modes** : mode | description ---|--- `1` | 1-bit bilevel, stored with the leftmost pixel in the most significant bit. 0 means black, 1 means white. `1;I` | 1-bit inverted bilevel, stored with the leftmost pixel in the most significant bit. 0 means white, 1 means black. `1;R` | 1-bit reversed bilevel, stored with the leftmost pixel in the least significant bit. 0 means black, 1 means white. `L` | 8-bit grayscale. 0 means black, 255 means white. `L;I` | 8-bit inverted grayscale. 0 means white, 255 means black. `P` | 8-bit palette-mapped image. `RGB` | 24-bit true colour, stored as (red, green, blue). `BGR` | 24-bit true colour, stored as (blue, green, red). `RGBX` | 24-bit true colour, stored as (red, green, blue, pad). The pad pixels may vary. `RGB;L` | 24-bit true colour, line interleaved (first all red pixels, then all green pixels, finally all blue pixels). Note that for the most common cases, the raw mode is simply the same as the mode. The Python Imaging Library supports many other decoders, including JPEG, PNG, and PackBits. For details, see the `decode.c` source file, and the standard plugin implementations provided with the library. ## Decoding floating point data¶ PIL provides some special mechanisms to allow you to load a wide variety of formats into a mode `F` (floating point) image memory. You can use the `raw` decoder to read images where data is packed in any standard machine data type, using one of the following raw modes: mode | description ---|--- `F` | 32-bit native floating point. `F;8` | 8-bit unsigned integer. `F;8S` | 8-bit signed integer. `F;16` | 16-bit little endian unsigned integer. `F;16S` | 16-bit little endian signed integer. `F;16B` | 16-bit big endian unsigned integer. `F;16BS` | 16-bit big endian signed integer. `F;16N` | 16-bit native unsigned integer. `F;16NS` | 16-bit native signed integer. `F;32` | 32-bit little endian unsigned integer. `F;32S` | 32-bit little endian signed integer. `F;32B` | 32-bit big endian unsigned integer. `F;32BS` | 32-bit big endian signed integer. `F;32N` | 32-bit native unsigned integer. `F;32NS` | 32-bit native signed integer. `F;32F` | 32-bit little endian floating point. `F;32BF` | 32-bit big endian floating point. `F;32NF` | 32-bit native floating point. `F;64F` | 64-bit little endian floating point. `F;64BF` | 64-bit big endian floating point. `F;64NF` | 64-bit native floating point. ## The bit decoder¶ If the raw decoder cannot handle your format, PIL also provides a special “bit” decoder that can be used to read various packed formats into a floating point image memory. To use the bit decoder with the [`PIL.Image.frombytes()`](../reference/Image.html#PIL.Image.frombytes "PIL.Image.frombytes") function, use the following syntax: image = Image.frombytes( mode, size, data, "bit", bits, pad, fill, sign, orientation ) When used in a tile descriptor, the parameter field should look like: (bits, pad, fill, sign, orientation) The fields are used as follows: **bits** Number of bits per pixel (2-32). No default. **pad** Padding between lines, in bits. This is either 0 if there is no padding, or 8 if lines are padded to full bytes. If omitted, the pad value defaults to 8. **fill** Controls how data are added to, and stored from, the decoder bit buffer. **fill=0** Add bytes to the LSB end of the decoder buffer; store pixels from the MSB end. **fill=1** Add bytes to the MSB end of the decoder buffer; store pixels from the MSB end. **fill=2** Add bytes to the LSB end of the decoder buffer; store pixels from the LSB end. **fill=3** Add bytes to the MSB end of the decoder buffer; store pixels from the LSB end. If omitted, the fill order defaults to 0. **sign** If non-zero, bit fields are sign extended. If zero or omitted, bit fields are unsigned. **orientation** Whether the first line in the image is the top line on the screen (1), or the bottom line (-1). If omitted, the orientation defaults to 1. # Writing your own file codec in C¶ There are 3 stages in a file codec’s lifetime: 1. Setup: Pillow looks for a function in the decoder or encoder registry, falling back to a function named `[codecname]_decoder` or `[codecname]_encoder` on the internal core image object. That function is called with the `args` tuple from the `tile`. 2. Transforming: The codec’s `decode` or `encode` function is repeatedly called with chunks of image data. 3. Cleanup: If the codec has registered a cleanup function, it will be called at the end of the transformation process, even if there was an exception raised. ## Setup¶ The current conventions are that the codec setup function is named `PyImaging_[codecname]DecoderNew` or `PyImaging_[codecname]EncoderNew` and defined in `decode.c` or `encode.c`. The Python binding for it is named `[codecname]_decoder` or `[codecname]_encoder` and is set up from within the `_imaging.c` file in the codecs section of the function array. The setup function needs to call `PyImaging_DecoderNew` or `PyImaging_EncoderNew` and at the very least, set the `decode` or `encode` function pointer. The fields of interest in this object are: **decode** /**encode** Function pointer to the decode or encode function, which has access to `im`, `state`, and the buffer of data to be transformed. **cleanup** Function pointer to the cleanup function, has access to `state`. **im** The target image, will be set by Pillow. **state** An ImagingCodecStateInstance, will be set by Pillow. The `context` member is an opaque struct that can be used by the codec to store any format specific state or options. **pulls_fd** /**pushes_fd** If the decoder has `pulls_fd` or the encoder has `pushes_fd` set to 1, `state->fd` will be a pointer to the Python file like object. The codec may use the functions in `codec_fd.c` to read or write directly with the file like object rather than have the data pushed through a buffer. Added in version 3.3.0. ## Transforming¶ The decode or encode function is called with the target (core) image, the codec state structure, and a buffer of data to be transformed. It is the codec’s responsibility to pull as much data as possible out of the buffer and return the number of bytes consumed. The next call to the codec will include the previous unconsumed tail. The codec function will be called multiple times as the data processed. Alternatively, if `pulls_fd` or `pushes_fd` is set, then the decode or encode function is called once, with an empty buffer. It is the codec’s responsibility to transform the entire tile in that one call. Using this will provide a codec with more freedom, but that freedom may mean increased memory usage if the entire tile is held in memory at once by the codec. If an error occurs, set `state->errcode` and return -1. Return -1 on success, without setting the errcode. ## Cleanup¶ The cleanup function is called after the codec returns a negative value, or if there is an error. This function should free any allocated memory and release any resources from external libraries. # Writing your own file codec in Python¶ Python file decoders and encoders should derive from [`PIL.ImageFile.PyDecoder`](../reference/ImageFile.html#PIL.ImageFile.PyDecoder "PIL.ImageFile.PyDecoder") and [`PIL.ImageFile.PyEncoder`](../reference/ImageFile.html#PIL.ImageFile.PyEncoder "PIL.ImageFile.PyEncoder") respectively, and should at least override the decode or encode method. They should be registered using [`PIL.Image.register_decoder()`](../reference/Image.html#PIL.Image.register_decoder "PIL.Image.register_decoder") and [`PIL.Image.register_encoder()`](../reference/Image.html#PIL.Image.register_encoder "PIL.Image.register_encoder"). As in the C implementation of the file codecs, there are three stages in the lifetime of a Python-based file codec: 1. Setup: Pillow looks for the codec in the decoder or encoder registry, then instantiates the class. 2. Transforming: The instance’s `decode` method is repeatedly called with a buffer of data to be interpreted, or the `encode` method is repeatedly called with the size of data to be output. Alternatively, if the decoder’s `_pulls_fd` property (or the encoder’s `_pushes_fd` property) is set to `True`, then `decode` and `encode` will only be called once. In the decoder, `self.fd` can be used to access the file-like object. Using this will provide a codec with more freedom, but that freedom may mean increased memory usage if entire file is held in memory at once by the codec. In `decode`, once the data has been interpreted, `set_as_raw` can be used to populate the image. 3. Cleanup: The instance’s `cleanup` method is called once the transformation is complete. This can be used to clean up any resources used by the codec. If you set `_pulls_fd` or `_pushes_fd` to `True` however, then you probably chose to perform any cleanup tasks at the end of `decode` or `encode`. For an example [`PIL.ImageFile.PyDecoder`](../reference/ImageFile.html#PIL.ImageFile.PyDecoder "PIL.ImageFile.PyDecoder"), see [DdsImagePlugin](https://github.com/python- pillow/Pillow/blob/main/docs/example/DdsImagePlugin.py). For a plugin that uses both [`PIL.ImageFile.PyDecoder`](../reference/ImageFile.html#PIL.ImageFile.PyDecoder "PIL.ImageFile.PyDecoder") and [`PIL.ImageFile.PyEncoder`](../reference/ImageFile.html#PIL.ImageFile.PyEncoder "PIL.ImageFile.PyEncoder"), see [BlpImagePlugin](https://github.com/python- pillow/Pillow/blob/main/src/PIL/BlpImagePlugin.py) [ Next Reference ](../reference/index.html) [ Previous Third-party plugins ](third-party-plugins.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * Writing your own image plugin * Example * The `tile` attribute * Decoders * The raw decoder * Decoding floating point data * The bit decoder * Writing your own file codec in C * Setup * Transforming * Cleanup * Writing your own file codec in Python --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/ # Path: index Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content Pillow (PIL Fork) 12.1.0.dev0 documentation ![Light Logo](_static/pillow-logo-dark-text.png) ![Dark Logo](_static/pillow- logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation * [Installation](installation/index.html) * [Basic installation](installation/basic-installation.html) * [Python support](installation/python-support.html) * [Platform support](installation/platform-support.html) * [Building from source](installation/building-from-source.html) * [Old versions](installation/building-from-source.html#old-versions) * [Handbook](handbook/index.html) * [Overview](handbook/overview.html) * [Tutorial](handbook/tutorial.html) * [Concepts](handbook/concepts.html) * [Appendices](handbook/appendices.html) * [Image file formats](handbook/image-file-formats.html) * [Text anchors](handbook/text-anchors.html) * [Third-party plugins](handbook/third-party-plugins.html) * [Writing your own image plugin](handbook/writing-your-own-image-plugin.html) * [Decoders](handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](reference/index.html) * [`Image` module](reference/Image.html) * [`ImageChops` (“channel operations”) module](reference/ImageChops.html) * [`ImageCms` module](reference/ImageCms.html) * [`ImageColor` module](reference/ImageColor.html) * [`ImageDraw` module](reference/ImageDraw.html) * [`ImageEnhance` module](reference/ImageEnhance.html) * [`ImageFile` module](reference/ImageFile.html) * [`ImageFilter` module](reference/ImageFilter.html) * [`ImageFont` module](reference/ImageFont.html) * [`ImageGrab` module](reference/ImageGrab.html) * [`ImageMath` module](reference/ImageMath.html) * [`ImageMorph` module](reference/ImageMorph.html) * [`ImageOps` module](reference/ImageOps.html) * [`ImagePalette` module](reference/ImagePalette.html) * [`ImagePath` module](reference/ImagePath.html) * [`ImageQt` module](reference/ImageQt.html) * [`ImageSequence` module](reference/ImageSequence.html) * [`ImageShow` module](reference/ImageShow.html) * [`ImageStat` module](reference/ImageStat.html) * [`ImageText` module](reference/ImageText.html) * [`ImageTk` module](reference/ImageTk.html) * [`ImageTransform` module](reference/ImageTransform.html) * [`ImageWin` module (Windows-only)](reference/ImageWin.html) * [`ExifTags` module](reference/ExifTags.html) * [`TiffTags` module](reference/TiffTags.html) * [`JpegPresets` module](reference/JpegPresets.html) * [`PSDraw` module](reference/PSDraw.html) * [`PixelAccess` class](reference/PixelAccess.html) * [`features` module](reference/features.html) * [PIL package (autodoc of remaining modules)](PIL.html) * [Plugin reference](reference/plugins.html) * [Internal reference](reference/internal_design.html) * [File handling in Pillow](reference/open_files.html) * [Limits](reference/limits.html) * [Block allocator](reference/block_allocator.html) * [Internal modules](reference/internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](reference/c_extension_debugging.html) * [Arrow support](reference/arrow_support.html) * [Porting](porting.html) * [About](about.html) * [Release notes](releasenotes/index.html) * [Versioning](releasenotes/versioning.html) * [12.1.0 (unreleased)](releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](releasenotes/2.3.1.html) * [Deprecations and removals](deprecations.html) Back to top [ View this page ](_sources/index.rst.txt "View this page") # Pillow¶ Pillow is the friendly PIL fork by [Jeffrey A. Clark and contributors](https://github.com/python-pillow/Pillow/graphs/contributors). PIL is the Python Imaging Library by Fredrik Lundh and contributors. Pillow for enterprise is available via the Tidelift Subscription. [Learn more](https://tidelift.com/subscription/pkg/pypi-pillow?utm_source=pypi- pillow&utm_medium=docs&utm_campaign=enterprise). [![Documentation Status](https://readthedocs.org/projects/pillow/badge/?version=latest) ](https://pillow.readthedocs.io/?badge=latest) [![GitHub Actions build status \(Lint\)](https://github.com/python-pillow/Pillow/workflows/Lint/badge.svg) ](https://github.com/python-pillow/Pillow/actions/workflows/lint.yml) [![GitHub Actions build status \(Test Docker\)](https://github.com/python- pillow/Pillow/workflows/Test%20Docker/badge.svg) ](https://github.com/python- pillow/Pillow/actions/workflows/test-docker.yml) [![GitHub Actions build status \(Test Linux and macOS\)](https://github.com/python- pillow/Pillow/workflows/Test/badge.svg) ](https://github.com/python- pillow/Pillow/actions/workflows/test.yml) [![GitHub Actions build status \(Test Windows\)](https://github.com/python- pillow/Pillow/workflows/Test%20Windows/badge.svg) ](https://github.com/python- pillow/Pillow/actions/workflows/test-windows.yml) [![GitHub Actions build status \(Test MinGW\)](https://github.com/python- pillow/Pillow/workflows/Test%20MinGW/badge.svg) ](https://github.com/python- pillow/Pillow/actions/workflows/test-mingw.yml) [![GitHub Actions build status \(Wheels\)](https://github.com/python- pillow/Pillow/workflows/Wheels/badge.svg) ](https://github.com/python- pillow/Pillow/actions/workflows/wheels.yml) [![Code coverage](https://codecov.io/gh/python- pillow/Pillow/branch/main/graph/badge.svg) ](https://app.codecov.io/gh/python- pillow/Pillow) [![Zenodo](https://zenodo.org/badge/17549/python- pillow/Pillow.svg) ](https://zenodo.org/badge/latestdoi/17549/python- pillow/Pillow) [![Tidelift](https://tidelift.com/badges/package/pypi/pillow?style=flat) ](https://tidelift.com/subscription/pkg/pypi-pillow?utm_source=pypi- pillow&utm_medium=badge) [![Fuzzing Status](https://oss-fuzz-build- logs.storage.googleapis.com/badges/pillow.svg) ](https://issues.oss- fuzz.com/issues?q=title:pillow) [![Latest PyPI version](https://img.shields.io/pypi/v/pillow.svg) ](https://pypi.org/project/pillow/) [![Number of PyPI downloads](https://img.shields.io/pypi/dm/pillow.svg) ](https://pypi.org/project/pillow/) [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/6331/badge) ](https://www.bestpractices.dev/projects/6331) [![Join the chat at https://gitter.im/python-pillow/Pillow](https://badges.gitter.im/python- pillow/Pillow.svg) ](https://gitter.im/python- pillow/Pillow?utm_source=badge&utm_medium=badge&utm_campaign=pr- badge&utm_content=badge) [![Follow on https://fosstodon.org/@pillow](https://img.shields.io/badge/publish- on%20Mastodon-595aff.svg) ](https://fosstodon.org/@pillow) # Overview¶ The Python Imaging Library adds image processing capabilities to your Python interpreter. This library provides extensive file format support, an efficient internal representation, and fairly powerful image processing capabilities. The core image library is designed for fast access to data stored in a few basic pixel formats. It should provide a solid foundation for a general image processing tool. * [Installation](installation/index.html) * [Basic installation](installation/basic-installation.html) * [Python support](installation/python-support.html) * [Platform support](installation/platform-support.html) * [Building from source](installation/building-from-source.html) * [Old versions](installation/building-from-source.html#old-versions) * [Handbook](handbook/index.html) * [Overview](handbook/overview.html) * [Tutorial](handbook/tutorial.html) * [Concepts](handbook/concepts.html) * [Appendices](handbook/appendices.html) * [Reference](reference/index.html) * [`Image` module](reference/Image.html) * [`ImageChops` (“channel operations”) module](reference/ImageChops.html) * [`ImageCms` module](reference/ImageCms.html) * [`ImageColor` module](reference/ImageColor.html) * [`ImageDraw` module](reference/ImageDraw.html) * [`ImageEnhance` module](reference/ImageEnhance.html) * [`ImageFile` module](reference/ImageFile.html) * [`ImageFilter` module](reference/ImageFilter.html) * [`ImageFont` module](reference/ImageFont.html) * [`ImageGrab` module](reference/ImageGrab.html) * [`ImageMath` module](reference/ImageMath.html) * [`ImageMorph` module](reference/ImageMorph.html) * [`ImageOps` module](reference/ImageOps.html) * [`ImagePalette` module](reference/ImagePalette.html) * [`ImagePath` module](reference/ImagePath.html) * [`ImageQt` module](reference/ImageQt.html) * [`ImageSequence` module](reference/ImageSequence.html) * [`ImageShow` module](reference/ImageShow.html) * [`ImageStat` module](reference/ImageStat.html) * [`ImageText` module](reference/ImageText.html) * [`ImageTk` module](reference/ImageTk.html) * [`ImageTransform` module](reference/ImageTransform.html) * [`ImageWin` module (Windows-only)](reference/ImageWin.html) * [`ExifTags` module](reference/ExifTags.html) * [`TiffTags` module](reference/TiffTags.html) * [`JpegPresets` module](reference/JpegPresets.html) * [`PSDraw` module](reference/PSDraw.html) * [`PixelAccess` class](reference/PixelAccess.html) * [`features` module](reference/features.html) * [PIL package (autodoc of remaining modules)](PIL.html) * [Plugin reference](reference/plugins.html) * [Internal reference](reference/internal_design.html) * [Porting](porting.html) * [About](about.html) * [Goals](about.html#goals) * [License](about.html#license) * [Why a fork?](about.html#why-a-fork) * [What about PIL?](about.html#what-about-pil) * [Release notes](releasenotes/index.html) * [Versioning](releasenotes/versioning.html) * [12.1.0 (unreleased)](releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](releasenotes/2.3.1.html) * [Deprecations and removals](deprecations.html) * [Deprecated features](deprecations.html#deprecated-features) * [Removed features](deprecations.html#removed-features) # Indices and tables¶ * [Index](genindex.html) * [Module Index](py-modindex.html) [ Next Installation ](installation/index.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/installation/basic-installation.html # Path: installation/basic-installation.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](index.html) * Basic installation * [Python support](python-support.html) * [Platform support](platform-support.html) * [Building from source](building-from-source.html) * [Old versions](building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](../reference/index.html) * [`Image` module](../reference/Image.html) * [`ImageChops` (“channel operations”) module](../reference/ImageChops.html) * [`ImageCms` module](../reference/ImageCms.html) * [`ImageColor` module](../reference/ImageColor.html) * [`ImageDraw` module](../reference/ImageDraw.html) * [`ImageEnhance` module](../reference/ImageEnhance.html) * [`ImageFile` module](../reference/ImageFile.html) * [`ImageFilter` module](../reference/ImageFilter.html) * [`ImageFont` module](../reference/ImageFont.html) * [`ImageGrab` module](../reference/ImageGrab.html) * [`ImageMath` module](../reference/ImageMath.html) * [`ImageMorph` module](../reference/ImageMorph.html) * [`ImageOps` module](../reference/ImageOps.html) * [`ImagePalette` module](../reference/ImagePalette.html) * [`ImagePath` module](../reference/ImagePath.html) * [`ImageQt` module](../reference/ImageQt.html) * [`ImageSequence` module](../reference/ImageSequence.html) * [`ImageShow` module](../reference/ImageShow.html) * [`ImageStat` module](../reference/ImageStat.html) * [`ImageText` module](../reference/ImageText.html) * [`ImageTk` module](../reference/ImageTk.html) * [`ImageTransform` module](../reference/ImageTransform.html) * [`ImageWin` module (Windows-only)](../reference/ImageWin.html) * [`ExifTags` module](../reference/ExifTags.html) * [`TiffTags` module](../reference/TiffTags.html) * [`JpegPresets` module](../reference/JpegPresets.html) * [`PSDraw` module](../reference/PSDraw.html) * [`PixelAccess` class](../reference/PixelAccess.html) * [`features` module](../reference/features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](../reference/plugins.html) * [Internal reference](../reference/internal_design.html) * [File handling in Pillow](../reference/open_files.html) * [Limits](../reference/limits.html) * [Block allocator](../reference/block_allocator.html) * [Internal modules](../reference/internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](../reference/c_extension_debugging.html) * [Arrow support](../reference/arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/installation/basic-installation.rst.txt "View this page") # Basic installation¶ Note The following instructions will install Pillow with support for most common image formats. See [External libraries](building-from-source.html#external- libraries) for a full list of external libraries supported. Install Pillow with **pip** : python3 -m pip install --upgrade pip python3 -m pip install --upgrade Pillow Optionally, install [defusedxml](https://pypi.org/project/defusedxml/) for Pillow to read XMP data, and [olefile](https://pypi.org/project/olefile/) for Pillow to read FPX and MIC images: python3 -m pip install --upgrade defusedxml olefile Linux We provide binaries for Linux for each of the supported Python versions in the manylinux wheel format. These include support for all optional libraries except libimagequant. Raqm support requires FriBiDi to be installed separately: python3 -m pip install --upgrade pip python3 -m pip install --upgrade Pillow Most major Linux distributions, including Fedora, Ubuntu and ArchLinux also include Pillow in packages that previously contained PIL e.g. `python- imaging`. Debian splits it into two packages, `python3-pil` and `python3-pil.imagetk`. macOS We provide binaries for macOS for each of the supported Python versions in the wheel format. These include support for all optional libraries except libimagequant. Raqm support requires FriBiDi to be installed separately: python3 -m pip install --upgrade pip python3 -m pip install --upgrade Pillow While we provide binaries for both x86-64 and arm64, we do not provide universal2 binaries. However, it is simple to combine our current binaries to create one: python3 -m pip download --only-binary=:all: --platform macosx_10_10_x86_64 Pillow python3 -m pip download --only-binary=:all: --platform macosx_11_0_arm64 Pillow python3 -m pip install delocate Then, with the names of the downloaded wheels, use Python to combine them: from delocate.fuse import fuse_wheels fuse_wheels('Pillow-9.4.0-2-cp39-cp39-macosx_10_10_x86_64.whl', 'Pillow-9.4.0-cp39-cp39-macosx_11_0_arm64.whl', 'Pillow-9.4.0-cp39-cp39-macosx_11_0_universal2.whl') Windows We provide Pillow binaries for Windows compiled for the matrix of supported Pythons in the wheel format. These include x86, x86-64 and arm64 versions. These binaries include support for all optional libraries except libimagequant and libxcb. Raqm support requires FriBiDi to be installed separately: python3 -m pip install --upgrade pip python3 -m pip install --upgrade Pillow To install Pillow in MSYS2, see [Building from source](building-from- source.html#building-from-source). FreeBSD Pillow can be installed on FreeBSD via the official Ports or Packages systems: **Ports** : cd /usr/ports/graphics/py-pillow && make install clean **Packages** : pkg install py38-pillow Note The [Pillow FreeBSD port](https://www.freshports.org/graphics/py-pillow/) and packages are tested by the ports team with all supported FreeBSD versions. [ Next Python support ](python-support.html) [ Previous Installation ](index.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/installation/building-from-source.html # Path: installation/building-from-source.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](index.html) * [Basic installation](basic-installation.html) * [Python support](python-support.html) * [Platform support](platform-support.html) * Building from source * Old versions * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](../reference/index.html) * [`Image` module](../reference/Image.html) * [`ImageChops` (“channel operations”) module](../reference/ImageChops.html) * [`ImageCms` module](../reference/ImageCms.html) * [`ImageColor` module](../reference/ImageColor.html) * [`ImageDraw` module](../reference/ImageDraw.html) * [`ImageEnhance` module](../reference/ImageEnhance.html) * [`ImageFile` module](../reference/ImageFile.html) * [`ImageFilter` module](../reference/ImageFilter.html) * [`ImageFont` module](../reference/ImageFont.html) * [`ImageGrab` module](../reference/ImageGrab.html) * [`ImageMath` module](../reference/ImageMath.html) * [`ImageMorph` module](../reference/ImageMorph.html) * [`ImageOps` module](../reference/ImageOps.html) * [`ImagePalette` module](../reference/ImagePalette.html) * [`ImagePath` module](../reference/ImagePath.html) * [`ImageQt` module](../reference/ImageQt.html) * [`ImageSequence` module](../reference/ImageSequence.html) * [`ImageShow` module](../reference/ImageShow.html) * [`ImageStat` module](../reference/ImageStat.html) * [`ImageText` module](../reference/ImageText.html) * [`ImageTk` module](../reference/ImageTk.html) * [`ImageTransform` module](../reference/ImageTransform.html) * [`ImageWin` module (Windows-only)](../reference/ImageWin.html) * [`ExifTags` module](../reference/ExifTags.html) * [`TiffTags` module](../reference/TiffTags.html) * [`JpegPresets` module](../reference/JpegPresets.html) * [`PSDraw` module](../reference/PSDraw.html) * [`PixelAccess` class](../reference/PixelAccess.html) * [`features` module](../reference/features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](../reference/plugins.html) * [Internal reference](../reference/internal_design.html) * [File handling in Pillow](../reference/open_files.html) * [Limits](../reference/limits.html) * [Block allocator](../reference/block_allocator.html) * [Internal modules](../reference/internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](../reference/c_extension_debugging.html) * [Arrow support](../reference/arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/installation/building-from-source.rst.txt "View this page") # Building from source¶ ## External libraries¶ Note You **do not need to install all supported external libraries** to use Pillow’s basic features. **Zlib** and **libjpeg** are required by default. Note There are Dockerfiles in our [Docker images repo](https://github.com/python- pillow/docker-images) to install the dependencies for some operating systems. Many of Pillow’s features require external libraries: * **libjpeg** provides JPEG functionality. * Pillow has been tested with libjpeg versions **6b** , **8** , **9-9d** and libjpeg-turbo version **8**. * Starting with Pillow 3.0.0, libjpeg is required by default. It can be disabled with the `-C jpeg=disable` flag. * **zlib** provides access to compressed PNGs * Starting with Pillow 3.0.0, zlib is required by default. It can be disabled with the `-C zlib=disable` flag. * **libtiff** provides compressed TIFF functionality * Pillow has been tested with libtiff versions **4.0-4.7.1** * **libfreetype** provides type related services * **littlecms** provides color management * Pillow version 2.2.1 and below uses liblcms1, Pillow 2.3.0 and above uses liblcms2. Tested with **1.19** and **2.7-2.17**. * **libwebp** provides the WebP format. * **openjpeg** provides JPEG 2000 functionality. * Pillow has been tested with openjpeg **2.0.0** , **2.1.0** , **2.3.1** , **2.4.0** , **2.5.0** , **2.5.2** , **2.5.3** and **2.5.4**. * Pillow does **not** support the earlier **1.5** series which ships with Debian Jessie. * **libimagequant** provides improved color quantization * Pillow has been tested with libimagequant **2.6-4.4.1** * Libimagequant is licensed GPLv3, which is more restrictive than the Pillow license, therefore we will not be distributing binaries with libimagequant support enabled. * **libraqm** provides complex text layout support. * libraqm provides bidirectional text support (using FriBiDi), shaping (using HarfBuzz), and proper script itemization. As a result, Raqm can support most writing systems covered by Unicode. * libraqm depends on the following libraries: FreeType, HarfBuzz, FriBiDi, make sure that you install them before installing libraqm if not available as package in your system. * Setting text direction or font features is not supported without libraqm. * Pillow wheels since version 8.2.0 include a modified version of libraqm that loads libfribidi at runtime if it is installed. On Windows this requires compiling FriBiDi and installing `fribidi.dll` into a directory listed in the [Dynamic-link library search order (Microsoft Learn)](https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#search-order-for-unpackaged-apps) (`fribidi-0.dll` or `libfribidi-0.dll` are also detected). See Build Options to see how to build this version. * Previous versions of Pillow (5.0.0 to 8.1.2) linked libraqm dynamically at runtime. * **libxcb** provides X11 screengrab support. * **libavif** provides support for the AVIF format. * Pillow requires libavif version **1.0.0** or greater. * libavif is merely an API that wraps AVIF codecs. If you are compiling libavif from source, you will also need to install both an AVIF encoder and decoder, such as rav1e and dav1d, or libaom, which both encodes and decodes AVIF images. Linux If you didn’t build Python from source, make sure you have Python’s development libraries installed. In Debian or Ubuntu: sudo apt-get install python3-dev python3-setuptools In Fedora, the command is: sudo dnf install python3-devel redhat-rpm-config In Alpine, the command is: sudo apk add python3-dev py3-setuptools Note `redhat-rpm-config` is required on Fedora 23, but not earlier versions. Prerequisites for **Ubuntu 16.04 LTS - 24.04 LTS** are installed with: sudo apt-get install libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev \ libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk \ libharfbuzz-dev libfribidi-dev libxcb1-dev To install libraqm, `sudo apt-get install meson` and then see `depends/install_raqm.sh`. Build prerequisites for libavif on Ubuntu are installed with: sudo apt-get install cmake ninja-build nasm Then see `depends/install_libavif.sh` to build and install libavif. Prerequisites are installed on recent **Red Hat** , **CentOS** or **Fedora** with: sudo dnf install libtiff-devel libjpeg-devel openjpeg2-devel zlib-devel \ freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel \ harfbuzz-devel fribidi-devel libraqm-devel libimagequant-devel libxcb-devel Note that the package manager may be yum or DNF, depending on the exact distribution. Prerequisites are installed for **Alpine** with: sudo apk add tiff-dev jpeg-dev openjpeg-dev zlib-dev freetype-dev lcms2-dev \ libwebp-dev tcl-dev tk-dev harfbuzz-dev fribidi-dev libimagequant-dev \ libxcb-dev libpng-dev See also the `Dockerfile`s in the Test Infrastructure repo () for a known working install process for other tested distros. macOS The Xcode command line tools are required to compile portions of Pillow. The tools are installed by running `xcode-select --install` from the command line. The command line tools are required even if you have the full Xcode package installed. It may be necessary to run `sudo xcodebuild -license` to accept the license prior to using the tools. The easiest way to install external libraries is via [Homebrew](https://brew.sh/). After you install Homebrew, run: brew install libavif libjpeg libraqm libtiff little-cms2 openjpeg webp If you would like to use libavif with more codecs than just aom, then instead of installing libavif through Homebrew directly, you can use Homebrew to install libavif’s build dependencies: brew install aom dav1d rav1e svt-av1 Then see `depends/install_libavif.sh` to install libavif. Windows We recommend you use prebuilt wheels from PyPI. If you wish to compile Pillow manually, you can use the build scripts in the `winbuild` directory used for CI testing and development. These scripts require Visual Studio 2017 or newer and NASM. The scripts also install Pillow from the local copy of the source code, so the Installing instructions will not be necessary afterwards. Windows using MSYS2/MinGW To build Pillow using MSYS2, make sure you run the **MSYS2 MinGW 32-bit** or **MSYS2 MinGW 64-bit** console, _not_ **MSYS2** directly. The following instructions target the 64-bit build, for 32-bit replace all occurrences of `mingw-w64-x86_64-` with `mingw-w64-i686-`. Make sure you have Python and GCC installed: pacman -S \ mingw-w64-x86_64-gcc \ mingw-w64-x86_64-python \ mingw-w64-x86_64-python-pip \ mingw-w64-x86_64-python-setuptools Prerequisites are installed on **MSYS2 MinGW 64-bit** with: pacman -S \ mingw-w64-x86_64-libjpeg-turbo \ mingw-w64-x86_64-zlib \ mingw-w64-x86_64-libtiff \ mingw-w64-x86_64-freetype \ mingw-w64-x86_64-lcms2 \ mingw-w64-x86_64-libwebp \ mingw-w64-x86_64-openjpeg2 \ mingw-w64-x86_64-libimagequant \ mingw-w64-x86_64-libraqm \ mingw-w64-x86_64-libavif FreeBSD Note Only FreeBSD 10 and 11 tested Make sure you have Python’s development libraries installed: sudo pkg install python3 Prerequisites are installed on **FreeBSD 10 or 11** with: sudo pkg install jpeg-turbo tiff webp lcms2 freetype2 openjpeg harfbuzz fribidi libxcb libavif Then see `depends/install_raqm_cmake.sh` to install libraqm. Android Basic Android support has been added for compilation within the Termux environment. The dependencies can be installed by: pkg install -y python ndk-sysroot clang make \ libjpeg-turbo This has been tested within the Termux app on ChromeOS, on x86. ## Installing¶ Once you have installed the prerequisites, to install Pillow from the source code on PyPI, run: python3 -m pip install --upgrade pip python3 -m pip install --upgrade Pillow --no-binary :all: If the prerequisites are installed in the standard library locations for your machine (e.g. `/usr` or `/usr/local`), no additional configuration should be required. If they are installed in a non-standard location, you may need to configure setuptools to use those locations by editing `setup.py` or `pyproject.toml`, or by adding environment variables on the command line: CFLAGS="-I/usr/pkg/include" python3 -m pip install --upgrade Pillow --no-binary :all: If Pillow has been previously built without the required prerequisites, it may be necessary to manually clear the pip cache or build without cache using the `--no-cache-dir` option to force a build with newly installed external libraries. If you would like to install from a local copy of the source code instead, you can clone from GitHub with `git clone https://github.com/python-pillow/Pillow` or download and extract the [compressed archive from PyPI](https://pypi.org/project/pillow/#files). After navigating to the Pillow directory, run: python3 -m pip install --upgrade pip python3 -m pip install . ### Build options¶ * Config setting: `-C parallel=n`. Can also be given with environment variable: `MAX_CONCURRENCY=n`. Pillow can use multiprocessing to build the extensions. Setting `-C parallel=n` sets the number of CPUs to use to `n`, or can disable parallel building by using a setting of 1. By default, it uses as many CPUs as are present. * Config settings: `-C zlib=disable`, `-C jpeg=disable`, `-C tiff=disable`, `-C freetype=disable`, `-C raqm=disable`, `-C lcms=disable`, `-C webp=disable`, `-C jpeg2000=disable`, `-C imagequant=disable`, `-C xcb=disable`, `-C avif=disable`. Disable building the corresponding feature even if the development libraries are present on the building machine. * Config settings: `-C zlib=enable`, `-C jpeg=enable`, `-C tiff=enable`, `-C freetype=enable`, `-C raqm=enable`, `-C lcms=enable`, `-C webp=enable`, `-C jpeg2000=enable`, `-C imagequant=enable`, `-C xcb=enable`, `-C avif=enable`. Require that the corresponding feature is built. The build will raise an exception if the libraries are not found. Tcl and Tk must be used together. * Config settings: `-C raqm=vendor`, `-C fribidi=vendor`. These flags are used to compile a modified version of libraqm and a shim that dynamically loads libfribidi at runtime. These are used to compile the standard Pillow wheels. Compiling libraqm requires a C99-compliant compiler. * Config setting: `-C platform-guessing=disable`. Skips all of the platform dependent guessing of include and library directories for automated build systems that configure the proper paths in the environment variables (e.g. Buildroot). * Config setting: `-C debug=true`. Adds a debugging flag to the include and library search process to dump all paths searched for and found to stdout. Sample usage: python3 -m pip install --upgrade Pillow -C [feature]=enable # Old versions¶ You can download old distributions from the [release history at PyPI](https://pypi.org/project/pillow/#history) and by direct URL access eg. . [ Next Handbook ](../handbook/index.html) [ Previous Platform support ](platform-support.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * Building from source * External libraries * Installing * Build options * Old versions --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/installation/index.html # Path: installation/index.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * Installation * [Basic installation](basic-installation.html) * [Python support](python-support.html) * [Platform support](platform-support.html) * [Building from source](building-from-source.html) * [Old versions](building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](../reference/index.html) * [`Image` module](../reference/Image.html) * [`ImageChops` (“channel operations”) module](../reference/ImageChops.html) * [`ImageCms` module](../reference/ImageCms.html) * [`ImageColor` module](../reference/ImageColor.html) * [`ImageDraw` module](../reference/ImageDraw.html) * [`ImageEnhance` module](../reference/ImageEnhance.html) * [`ImageFile` module](../reference/ImageFile.html) * [`ImageFilter` module](../reference/ImageFilter.html) * [`ImageFont` module](../reference/ImageFont.html) * [`ImageGrab` module](../reference/ImageGrab.html) * [`ImageMath` module](../reference/ImageMath.html) * [`ImageMorph` module](../reference/ImageMorph.html) * [`ImageOps` module](../reference/ImageOps.html) * [`ImagePalette` module](../reference/ImagePalette.html) * [`ImagePath` module](../reference/ImagePath.html) * [`ImageQt` module](../reference/ImageQt.html) * [`ImageSequence` module](../reference/ImageSequence.html) * [`ImageShow` module](../reference/ImageShow.html) * [`ImageStat` module](../reference/ImageStat.html) * [`ImageText` module](../reference/ImageText.html) * [`ImageTk` module](../reference/ImageTk.html) * [`ImageTransform` module](../reference/ImageTransform.html) * [`ImageWin` module (Windows-only)](../reference/ImageWin.html) * [`ExifTags` module](../reference/ExifTags.html) * [`TiffTags` module](../reference/TiffTags.html) * [`JpegPresets` module](../reference/JpegPresets.html) * [`PSDraw` module](../reference/PSDraw.html) * [`PixelAccess` class](../reference/PixelAccess.html) * [`features` module](../reference/features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](../reference/plugins.html) * [Internal reference](../reference/internal_design.html) * [File handling in Pillow](../reference/open_files.html) * [Limits](../reference/limits.html) * [Block allocator](../reference/block_allocator.html) * [Internal modules](../reference/internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](../reference/c_extension_debugging.html) * [Arrow support](../reference/arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/installation/index.rst.txt "View this page") # Installation¶ * [Basic installation](basic-installation.html) * [Python support](python-support.html) * [Platform support](platform-support.html) * [Continuous integration targets](platform-support.html#continuous-integration-targets) * [Other platforms](platform-support.html#other-platforms) * [Building from source](building-from-source.html) * [External libraries](building-from-source.html#external-libraries) * [Installing](building-from-source.html#installing) * [Old versions](building-from-source.html#old-versions) [ Next Basic installation ](basic-installation.html) [ Previous Home ](../index.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/installation/platform-support.html # Path: installation/platform-support.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](index.html) * [Basic installation](basic-installation.html) * [Python support](python-support.html) * Platform support * [Building from source](building-from-source.html) * [Old versions](building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](../reference/index.html) * [`Image` module](../reference/Image.html) * [`ImageChops` (“channel operations”) module](../reference/ImageChops.html) * [`ImageCms` module](../reference/ImageCms.html) * [`ImageColor` module](../reference/ImageColor.html) * [`ImageDraw` module](../reference/ImageDraw.html) * [`ImageEnhance` module](../reference/ImageEnhance.html) * [`ImageFile` module](../reference/ImageFile.html) * [`ImageFilter` module](../reference/ImageFilter.html) * [`ImageFont` module](../reference/ImageFont.html) * [`ImageGrab` module](../reference/ImageGrab.html) * [`ImageMath` module](../reference/ImageMath.html) * [`ImageMorph` module](../reference/ImageMorph.html) * [`ImageOps` module](../reference/ImageOps.html) * [`ImagePalette` module](../reference/ImagePalette.html) * [`ImagePath` module](../reference/ImagePath.html) * [`ImageQt` module](../reference/ImageQt.html) * [`ImageSequence` module](../reference/ImageSequence.html) * [`ImageShow` module](../reference/ImageShow.html) * [`ImageStat` module](../reference/ImageStat.html) * [`ImageText` module](../reference/ImageText.html) * [`ImageTk` module](../reference/ImageTk.html) * [`ImageTransform` module](../reference/ImageTransform.html) * [`ImageWin` module (Windows-only)](../reference/ImageWin.html) * [`ExifTags` module](../reference/ExifTags.html) * [`TiffTags` module](../reference/TiffTags.html) * [`JpegPresets` module](../reference/JpegPresets.html) * [`PSDraw` module](../reference/PSDraw.html) * [`PixelAccess` class](../reference/PixelAccess.html) * [`features` module](../reference/features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](../reference/plugins.html) * [Internal reference](../reference/internal_design.html) * [File handling in Pillow](../reference/open_files.html) * [Limits](../reference/limits.html) * [Block allocator](../reference/block_allocator.html) * [Internal modules](../reference/internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](../reference/c_extension_debugging.html) * [Arrow support](../reference/arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/installation/platform-support.rst.txt "View this page") # Platform support¶ Current platform support for Pillow. Binary distributions are contributed for each release on a volunteer basis, but the source should compile and run everywhere platform support is listed. In general, we aim to support all current versions of Linux, macOS, and Windows. ## Continuous integration targets¶ These platforms are built and tested for every change. Operating system | Tested Python versions | Tested architecture ---|---|--- Alpine | 3.12 | x86-64 Amazon Linux 2 | 3.10 | x86-64 Amazon Linux 2023 | 3.11 | x86-64 Arch | 3.13 | x86-64 CentOS Stream 9 | 3.10 | x86-64 CentOS Stream 10 | 3.12 | x86-64 Debian 12 Bookworm | 3.11 | x86, x86-64 Debian 13 Trixie | 3.13 | x86, x86-64 Fedora 42 | 3.13 | x86-64 Fedora 43 | 3.14 | x86-64 Gentoo | 3.12 | x86-64 macOS 15 Sequoia | 3.10 | x86-64 3.11, 3.12, 3.13, 3.14, PyPy3 | arm64 Ubuntu Linux 22.04 LTS (Jammy) | 3.10 | x86-64 Ubuntu Linux 24.04 LTS (Noble) | 3.10, 3.11, 3.12, 3.13, 3.14, PyPy3 | x86-64 3.12 | arm64v8, ppc64le, s390x Windows Server 2022 | 3.10 | x86 Windows Server 2025 | 3.11, 3.12, 3.13, 3.14, PyPy3 | x86-64 3.12 (MinGW) | x86-64 ## Other platforms¶ These platforms have been reported to work at the versions mentioned. Note Contributors please test Pillow on your platform then update this document and send a pull request. Operating system | Tested Python versions | Latest tested Pillow version | Tested processors ---|---|---|--- macOS 26 Tahoe | 3.10, 3.11, 3.12, 3.13, 3.14 | 12.0.0 | arm 3.9 | 11.3.0 macOS 15 Sequoia | 3.9, 3.10, 3.11, 3.12, 3.13 | 11.3.0 | arm 3.8 | 10.4.0 macOS 14 Sonoma | 3.8, 3.9, 3.10, 3.11, 3.12 | 10.4.0 | arm macOS 13 Ventura | 3.8, 3.9, 3.10, 3.11 | 10.0.1 | arm 3.7 | 9.5.0 macOS 12 Monterey | 3.7, 3.8, 3.9, 3.10, 3.11 | 9.3.0 | arm macOS 11 Big Sur | 3.7, 3.8, 3.9, 3.10 | 8.4.0 | arm 3.7, 3.8, 3.9, 3.10, 3.11 | 9.4.0 | x86-64 3.6 | 8.4.0 macOS 10.15 Catalina | 3.6, 3.7, 3.8, 3.9 | 8.3.2 | x86-64 3.5 | 7.2.0 macOS 10.14 Mojave | 3.5, 3.6, 3.7, 3.8 | 7.2.0 | x86-64 2.7 | 6.0.0 3.4 | 5.4.1 macOS 10.13 High Sierra | 2.7, 3.4, 3.5, 3.6 | 4.2.1 | x86-64 macOS 10.12 Sierra | 2.7, 3.4, 3.5, 3.6 | 4.1.1 | x86-64 Mac OS X 10.11 El Capitan | 2.7, 3.4, 3.5, 3.6, 3.7 | 5.4.1 | x86-64 3.3 | 4.1.0 Mac OS X 10.9 Mavericks | 2.7, 3.2, 3.3, 3.4 | 3.0.0 | x86-64 Mac OS X 10.8 Mountain Lion | 2.6, 2.7, 3.2, 3.3 | | x86-64 Redhat Linux 6 | 2.6 | | x86 CentOS 6.3 | 2.7, 3.3 | | x86 CentOS 8 | 3.9 | 9.0.0 | x86-64 Fedora 23 | 2.7, 3.4 | 3.1.0 | x86-64 Ubuntu Linux 12.04 LTS (Precise) | 2.6, 3.2, 3.3, 3.4, 3.5 PyPy5.3.1, PyPy3 v2.4.0 | 3.4.1 | x86,x86-64 2.7 | 4.3.0 | x86-64 2.7, 3.2 | 3.4.1 | ppc Ubuntu Linux 10.04 LTS (Lucid) | 2.6 | 2.3.0 | x86,x86-64 Debian 8.2 Jessie | 2.7, 3.4 | 3.1.0 | x86-64 Raspbian Jessie | 2.7, 3.4 | 3.1.0 | arm Raspbian Stretch | 2.7, 3.5 | 4.0.0 | arm Raspberry Pi OS | 3.6, 3.7, 3.8, 3.9 | 8.2.0 | arm 2.7 | 6.2.2 Gentoo Linux | 2.7, 3.2 | 2.1.0 | x86-64 FreeBSD 11.1 | 2.7, 3.4, 3.5, 3.6 | 4.3.0 | x86-64 FreeBSD 10.3 | 2.7, 3.4, 3.5 | 4.2.0 | x86-64 FreeBSD 10.2 | 2.7, 3.4 | 3.1.0 | x86-64 Windows 11 23H2 | 3.9, 3.10, 3.11, 3.12, 3.13 | 11.0.0 | arm64 Windows 11 Pro | 3.11, 3.12 | 10.2.0 | x86-64 Windows 10 | 3.7 | 7.1.0 | x86-64 Windows 10/Cygwin 3.3 | 3.6, 3.7, 3.8, 3.9 | 8.4.0 | x86-64 Windows 8.1 Pro | 2.6, 2.7, 3.2, 3.3, 3.4 | 2.4.0 | x86,x86-64 Windows 8 Pro | 2.6, 2.7, 3.2, 3.3, 3.4a3 | 2.2.0 | x86,x86-64 Windows 7 Professional | 3.7 | 7.0.0 | x86,x86-64 Windows Server 2008 R2 Enterprise | 3.3 | | x86-64 [ Next Building from source ](building-from-source.html) [ Previous Python support ](python-support.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * Platform support * Continuous integration targets * Other platforms --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/installation/python-support.html # Path: installation/python-support.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](index.html) * [Basic installation](basic-installation.html) * Python support * [Platform support](platform-support.html) * [Building from source](building-from-source.html) * [Old versions](building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](../reference/index.html) * [`Image` module](../reference/Image.html) * [`ImageChops` (“channel operations”) module](../reference/ImageChops.html) * [`ImageCms` module](../reference/ImageCms.html) * [`ImageColor` module](../reference/ImageColor.html) * [`ImageDraw` module](../reference/ImageDraw.html) * [`ImageEnhance` module](../reference/ImageEnhance.html) * [`ImageFile` module](../reference/ImageFile.html) * [`ImageFilter` module](../reference/ImageFilter.html) * [`ImageFont` module](../reference/ImageFont.html) * [`ImageGrab` module](../reference/ImageGrab.html) * [`ImageMath` module](../reference/ImageMath.html) * [`ImageMorph` module](../reference/ImageMorph.html) * [`ImageOps` module](../reference/ImageOps.html) * [`ImagePalette` module](../reference/ImagePalette.html) * [`ImagePath` module](../reference/ImagePath.html) * [`ImageQt` module](../reference/ImageQt.html) * [`ImageSequence` module](../reference/ImageSequence.html) * [`ImageShow` module](../reference/ImageShow.html) * [`ImageStat` module](../reference/ImageStat.html) * [`ImageText` module](../reference/ImageText.html) * [`ImageTk` module](../reference/ImageTk.html) * [`ImageTransform` module](../reference/ImageTransform.html) * [`ImageWin` module (Windows-only)](../reference/ImageWin.html) * [`ExifTags` module](../reference/ExifTags.html) * [`TiffTags` module](../reference/TiffTags.html) * [`JpegPresets` module](../reference/JpegPresets.html) * [`PSDraw` module](../reference/PSDraw.html) * [`PixelAccess` class](../reference/PixelAccess.html) * [`features` module](../reference/features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](../reference/plugins.html) * [Internal reference](../reference/internal_design.html) * [File handling in Pillow](../reference/open_files.html) * [Limits](../reference/limits.html) * [Block allocator](../reference/block_allocator.html) * [Internal modules](../reference/internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](../reference/c_extension_debugging.html) * [Arrow support](../reference/arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/installation/python-support.rst.txt "View this page") # Python support¶ Pillow supports these Python versions. Newer versions¶ Python | 3.14 | 3.13 | 3.12 | 3.11 | 3.10 | 3.9 | 3.8 | 3.7 | 3.6 | 3.5 ---|---|---|---|---|---|---|---|---|---|--- Pillow 12 | Yes | Yes | Yes | Yes | Yes | | | | | Pillow 11 | | Yes | Yes | Yes | Yes | Yes | | | | Pillow 10.1 - 10.4 | | | Yes | Yes | Yes | Yes | Yes | | | Pillow 10.0 | | | | Yes | Yes | Yes | Yes | | | Pillow 9.3 - 9.5 | | | | Yes | Yes | Yes | Yes | Yes | | Pillow 9.0 - 9.2 | | | | | Yes | Yes | Yes | Yes | | Pillow 8.3.2 - 8.4 | | | | | Yes | Yes | Yes | Yes | Yes | Pillow 8.0 - 8.3.1 | | | | | | Yes | Yes | Yes | Yes | Pillow 7.0 - 7.2 | | | | | | | Yes | Yes | Yes | Yes Older versions¶ Python | 3.8 | 3.7 | 3.6 | 3.5 | 3.4 | 3.3 | 3.2 | 2.7 | 2.6 | 2.5 | 2.4 ---|---|---|---|---|---|---|---|---|---|---|--- Pillow 6.2.1 - 6.2.2 | Yes | Yes | Yes | Yes | | | | Yes | | | Pillow 6.0 - 6.2.0 | | Yes | Yes | Yes | | | | Yes | | | Pillow 5.2 - 5.4 | | Yes | Yes | Yes | Yes | | | Yes | | | Pillow 5.0 - 5.1 | | | Yes | Yes | Yes | | | Yes | | | Pillow 4 | | | Yes | Yes | Yes | Yes | | Yes | | | Pillow 2 - 3 | | | | Yes | Yes | Yes | Yes | Yes | Yes | | Pillow < 2 | | | | | | | | Yes | Yes | Yes | Yes [ Next Platform support ](platform-support.html) [ Previous Basic installation ](basic-installation.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/Image.html # Path: reference/Image.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * `Image` module * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/Image.rst.txt "View this page") # `Image` module¶ The `Image` module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, and to create new images. ## Examples¶ ### Open, rotate, and display an image (using the default viewer)¶ The following script loads an image, rotates it 45 degrees, and displays it using an external viewer (usually xv on Unix, and the Paint program on Windows). from PIL import Image with Image.open("hopper.jpg") as im: im.rotate(45).show() ### Create thumbnails¶ The following script creates nice thumbnails of all JPEG images in the current directory preserving aspect ratios with 128x128 max resolution. from PIL import Image import glob, os size = 128, 128 for infile in glob.glob("*.jpg"): file, ext = os.path.splitext(infile) with Image.open(infile) as im: im.thumbnail(size) im.save(file + ".thumbnail", "JPEG") ## Functions¶ PIL.Image.open(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _mode : Literal['r'] = 'r'_, _formats : [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")] | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), ...] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [ImageFile.ImageFile](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile")[[source]](../_modules/PIL/Image.html#open)¶ Opens and identifies the given image file. This is a lazy operation; this function identifies the file, but the file remains open and the actual image data is not read from the file until you try to process the data (or call the `load()` method). See `new()`. See [File handling in Pillow](open_files.html#file-handling). Parameters: * **fp** – A filename (string), os.PathLike object or a file object. The file object must implement `file.read`, `file.seek`, and `file.tell` methods, and be opened in binary mode. The file object will also seek to zero before reading. * **mode** – The mode. If given, this argument must be “r”. * **formats** – A list or tuple of formats to attempt to load the file in. This can be used to restrict the set of formats checked. Pass `None` to try all supported formats. You can print the set of available formats by running `python3 -m PIL` or using the [`PIL.features.pilinfo()`](features.html#PIL.features.pilinfo "PIL.features.pilinfo") function. Returns: An `Image` object. Raises: * [**FileNotFoundError**](https://docs.python.org/3/library/exceptions.html#FileNotFoundError "\(in Python v3.14\)") – If the file cannot be found. * [**PIL.UnidentifiedImageError**](../PIL.html#PIL.UnidentifiedImageError "PIL.UnidentifiedImageError") – If the image cannot be opened and identified. * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "\(in Python v3.14\)") – If the `mode` is not “r”, or if a `StringIO` instance is used for `fp`. * [**TypeError**](https://docs.python.org/3/library/exceptions.html#TypeError "\(in Python v3.14\)") – If `formats` is not `None`, a list or a tuple. Warning To protect against potential DOS attacks caused by “[decompression bombs](https://en.wikipedia.org/wiki/Zip_bomb)” (i.e. malicious files which decompress into a huge amount of data and are designed to crash or cause disruption by using up a lot of memory), Pillow will issue a `DecompressionBombWarning` if the number of pixels in an image is over a certain limit, `MAX_IMAGE_PIXELS`. This threshold can be changed by setting `MAX_IMAGE_PIXELS`. It can be disabled by setting `Image.MAX_IMAGE_PIXELS = None`. If desired, the warning can be turned into an error with `warnings.simplefilter('error', Image.DecompressionBombWarning)` or suppressed entirely with `warnings.simplefilter('ignore', Image.DecompressionBombWarning)`. See also [the logging documentation](https://docs.python.org/3/library/logging.html#integration- with-the-warnings-module) to have warnings output to the logging facility instead of stderr. If the number of pixels is greater than twice `MAX_IMAGE_PIXELS`, then a `DecompressionBombError` will be raised instead. ### Image processing¶ PIL.Image.alpha_composite(_im1 : Image_, _im2 : Image_) -> Image[[source]](../_modules/PIL/Image.html#alpha_composite)¶ Alpha composite im2 over im1. Parameters: * **im1** – The first image. Must have mode RGBA or LA. * **im2** – The second image. Must have the same mode and size as the first image. Returns: An `Image` object. PIL.Image.blend(_im1 : Image_, _im2 : Image_, _alpha : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")_) -> Image[[source]](../_modules/PIL/Image.html#blend)¶ Creates a new image by interpolating between two input images, using a constant alpha: out = image1 * (1.0 - alpha) + image2 * alpha Parameters: * **im1** – The first image. * **im2** – The second image. Must have the same mode and size as the first image. * **alpha** – The interpolation alpha factor. If alpha is 0.0, a copy of the first image is returned. If alpha is 1.0, a copy of the second image is returned. There are no restrictions on the alpha value. If necessary, the result is clipped to fit into the allowed output range. Returns: An `Image` object. PIL.Image.composite(_image1 : Image_, _image2 : Image_, _mask : Image_) -> Image[[source]](../_modules/PIL/Image.html#composite)¶ Create composite image by blending images using a transparency mask. Parameters: * **image1** – The first image. * **image2** – The second image. Must have the same mode and size as the first image. * **mask** – A mask image. This image can have mode “1”, “L”, or “RGBA”, and must have the same size as the other two images. PIL.Image.eval(_image : Image_, _* args: Callable[[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")], [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]_) -> Image[[source]](../_modules/PIL/Image.html#eval)¶ Applies the function (which should take one argument) to each pixel in the given image. If the image has more than one band, the same function is applied to each band. Note that the function is evaluated once for each possible pixel value, so you cannot use random components or other generators. Parameters: * **image** – The input image. * **function** – A function object, taking one integer argument. Returns: An `Image` object. PIL.Image.merge(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _bands : Sequence[Image]_) -> Image[[source]](../_modules/PIL/Image.html#merge)¶ Merge a set of single band images into a new multiband image. Parameters: * **mode** – The mode to use for the output image. See: [Modes](../handbook/concepts.html#concept-modes). * **bands** – A sequence containing one single-band image for each band in the output image. All bands must have the same size. Returns: An `Image` object. ### Constructing images¶ PIL.Image.new(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _color : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), ...] | [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = 0_) -> Image[[source]](../_modules/PIL/Image.html#new)¶ Creates a new image with the given mode and size. Parameters: * **mode** – The mode to use for the new image. See: [Modes](../handbook/concepts.html#concept-modes). * **size** – A 2-tuple, containing (width, height) in pixels. * **color** – What color to use for the image. Default is black. If given, this should be a single integer or floating point value for single-band modes, and a tuple for multi-band modes (one value per band). When creating RGB or HSV images, you can also use color strings as supported by the ImageColor module. See [Colors](../handbook/concepts.html#colors) for more information. If the color is None, the image is not initialised. Returns: An `Image` object. PIL.Image.fromarray(_obj : SupportsArrayInterface_, _mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> Image[[source]](../_modules/PIL/Image.html#fromarray)¶ Creates an image memory from an object exporting the array interface (using the buffer protocol): from PIL import Image import numpy as np a = np.zeros((5, 5)) im = Image.fromarray(a) If `obj` is not contiguous, then the `tobytes` method is called and `frombuffer()` is used. In the case of NumPy, be aware that Pillow modes do not always correspond to NumPy dtypes. Pillow modes only offer 1-bit pixels, 8-bit pixels, 32-bit signed integer pixels, and 32-bit floating point pixels. Pillow images can also be converted to arrays: from PIL import Image import numpy as np im = Image.open("hopper.jpg") a = np.asarray(im) When converting Pillow images to arrays however, only pixel values are transferred. This means that P and PA mode images will lose their palette. Parameters: * **obj** – Object with array interface * **mode** – Optional mode to use when reading `obj`. Since pixel values do not contain information about palettes or color spaces, this can be used to place grayscale L mode data within a P mode image, or read RGB data as YCbCr for example. See: [Modes](../handbook/concepts.html#concept-modes) for general information about modes. Returns: An image object. Added in version 1.1.6. PIL.Image.fromarrow(_obj : SupportsArrowArrayInterface_, _mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_) -> Image[[source]](../_modules/PIL/Image.html#fromarrow)¶ Creates an image with zero-copy shared memory from an object exporting the arrow_c_array interface protocol: from PIL import Image import pyarrow as pa arr = pa.array([0]*(5*5*4), type=pa.uint8()) im = Image.fromarrow(arr, 'RGBA', (5, 5)) If the data representation of the `obj` is not compatible with Pillow internal storage, a ValueError is raised. Pillow images can also be converted to Arrow objects: from PIL import Image import pyarrow as pa im = Image.open('hopper.jpg') arr = pa.array(im) As with array support, when converting Pillow images to arrays, only pixel values are transferred. This means that P and PA mode images will lose their palette. Parameters: * **obj** – Object with an arrow_c_array interface * **mode** – Image mode. * **size** – Image size. This must match the storage of the arrow object. Returns: An Image object Note that according to the Arrow spec, both the producer and the consumer should consider the exported array to be immutable, as unsynchronized updates will potentially cause inconsistent data. See: [Arrow support](arrow_support.html#arrow-support) for more detailed information Added in version 11.2.1. PIL.Image.frombytes(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [bytearray](https://docs.python.org/3/library/stdtypes.html#bytearray "\(in Python v3.14\)") | SupportsArrayInterface_, _decoder_name : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") = 'raw'_, _* args: Any_) -> Image[[source]](../_modules/PIL/Image.html#frombytes)¶ Creates a copy of an image memory from pixel data in a buffer. In its simplest form, this function takes three arguments (mode, size, and unpacked pixel data). You can also use any pixel decoder supported by PIL. For more information on available decoders, see the section [Writing Your Own File Codec](../handbook/writing-your-own-image-plugin.html#file-codecs). Note that this function decodes pixel data only, not entire images. If you have an entire image in a string, wrap it in a [`BytesIO`](https://docs.python.org/3/library/io.html#io.BytesIO "\(in Python v3.14\)") object, and use `open()` to load it. Parameters: * **mode** – The image mode. See: [Modes](../handbook/concepts.html#concept-modes). * **size** – The image size. * **data** – A byte buffer containing raw data for the given mode. * **decoder_name** – What decoder to use. * **args** – Additional parameters for the given decoder. Returns: An `Image` object. PIL.Image.frombuffer(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | SupportsArrayInterface_, _decoder_name : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") = 'raw'_, _* args: Any_) -> Image[[source]](../_modules/PIL/Image.html#frombuffer)¶ Creates an image memory referencing pixel data in a byte buffer. This function is similar to `frombytes()`, but uses data in the byte buffer, where possible. This means that changes to the original buffer object are reflected in this image). Not all modes can share memory; supported modes include “L”, “RGBX”, “RGBA”, and “CMYK”. Note that this function decodes pixel data only, not entire images. If you have an entire image file in a string, wrap it in a [`BytesIO`](https://docs.python.org/3/library/io.html#io.BytesIO "\(in Python v3.14\)") object, and use `open()` to load it. The default parameters used for the “raw” decoder differs from that used for `frombytes()`. This is a bug, and will probably be fixed in a future release. The current release issues a warning if you do this; to disable the warning, you should provide the full set of parameters. See below for details. Parameters: * **mode** – The image mode. See: [Modes](../handbook/concepts.html#concept-modes). * **size** – The image size. * **data** – A bytes or other buffer object containing raw data for the given mode. * **decoder_name** – What decoder to use. * **args** – Additional parameters for the given decoder. For the default encoder (“raw”), it’s recommended that you provide the full set of parameters: frombuffer(mode, size, data, "raw", mode, 0, 1) Returns: An `Image` object. Added in version 1.1.4. ### Generating images¶ PIL.Image.effect_mandelbrot(_size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _extent : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]_, _quality : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> Image[[source]](../_modules/PIL/Image.html#effect_mandelbrot)¶ Generate a Mandelbrot set covering the given extent. Parameters: * **size** – The requested size in pixels, as a 2-tuple: (width, height). * **extent** – The extent to cover, as a 4-tuple: (x0, y0, x1, y1). * **quality** – Quality. PIL.Image.effect_noise(_size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _sigma : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")_) -> Image[[source]](../_modules/PIL/Image.html#effect_noise)¶ Generate Gaussian noise centered around 128. Parameters: * **size** – The requested size in pixels, as a 2-tuple: (width, height). * **sigma** – Standard deviation of noise. PIL.Image.linear_gradient(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> Image[[source]](../_modules/PIL/Image.html#linear_gradient)¶ Generate 256x256 linear gradient from black to white, top to bottom. Parameters: **mode** – Input mode. PIL.Image.radial_gradient(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> Image[[source]](../_modules/PIL/Image.html#radial_gradient)¶ Generate 256x256 radial gradient from black to white, centre to edge. Parameters: **mode** – Input mode. ### Registering plugins¶ PIL.Image.preinit() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#preinit)¶ Explicitly loads BMP, GIF, JPEG, PPM and PPM file format drivers. It is called when opening or saving images. PIL.Image.init() -> [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#init)¶ Explicitly initializes the Python Imaging Library. This function loads all available file format drivers. It is called when opening or saving images if `preinit()` is insufficient, and by [`pilinfo()`](features.html#PIL.features.pilinfo "PIL.features.pilinfo"). Note These functions are for use by plugin authors. They are called when a plugin is loaded as part of `preinit()` or `init()`. Application authors can ignore them. PIL.Image.register_open(_id : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _factory : Callable[[IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")], [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")], [ImageFile.ImageFile](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile")] | [type](https://docs.python.org/3/library/functions.html#type "\(in Python v3.14\)")[[ImageFile.ImageFile](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile")]_, _accept : Callable[[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")], [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") | [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#register_open)¶ Register an image file plugin. This function should not be used in application code. Parameters: * **id** – An image format identifier. * **factory** – An image file factory method. * **accept** – An optional function that can be used to quickly reject images having another format. PIL.Image.register_mime(_id : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _mimetype : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#register_mime)¶ Registers an image MIME type by populating `Image.MIME`. This function should not be used in application code. `Image.MIME` provides a mapping from image format identifiers to mime formats, but [`get_format_mimetype()`](ImageFile.html#PIL.ImageFile.ImageFile.get_format_mimetype "PIL.ImageFile.ImageFile.get_format_mimetype") can provide a different result for specific images. Parameters: * **id** – An image format identifier. * **mimetype** – The image MIME type for this format. PIL.Image.register_save(_id : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _driver : Callable[[Image, IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")], [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")], [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")]_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#register_save)¶ Registers an image save function. This function should not be used in application code. Parameters: * **id** – An image format identifier. * **driver** – A function to save images in this format. PIL.Image.register_save_all(_id : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _driver : Callable[[Image, IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")], [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")], [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")]_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#register_save_all)¶ Registers an image function to save all the frames of a multiframe format. This function should not be used in application code. Parameters: * **id** – An image format identifier. * **driver** – A function to save images in this format. PIL.Image.register_extension(_id : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _extension : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#register_extension)¶ Registers an image extension. This function should not be used in application code. Parameters: * **id** – An image format identifier. * **extension** – An extension used for this format. PIL.Image.register_extensions(_id : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _extensions : [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")]_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#register_extensions)¶ Registers image extensions. This function should not be used in application code. Parameters: * **id** – An image format identifier. * **extensions** – A list of extensions used for this format. PIL.Image.registered_extensions() -> [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")][[source]](../_modules/PIL/Image.html#registered_extensions)¶ Returns a dictionary containing all file extensions belonging to registered plugins PIL.Image.register_decoder(_name : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _decoder : [type](https://docs.python.org/3/library/functions.html#type "\(in Python v3.14\)")[[ImageFile.PyDecoder](ImageFile.html#PIL.ImageFile.PyDecoder "PIL.ImageFile.PyDecoder")]_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#register_decoder)¶ Registers an image decoder. This function should not be used in application code. Parameters: * **name** – The name of the decoder * **decoder** – An ImageFile.PyDecoder object Added in version 4.1.0. PIL.Image.register_encoder(_name : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _encoder : [type](https://docs.python.org/3/library/functions.html#type "\(in Python v3.14\)")[[ImageFile.PyEncoder](ImageFile.html#PIL.ImageFile.PyEncoder "PIL.ImageFile.PyEncoder")]_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#register_encoder)¶ Registers an image encoder. This function should not be used in application code. Parameters: * **name** – The name of the encoder * **encoder** – An ImageFile.PyEncoder object Added in version 4.1.0. ## The Image class¶ class PIL.Image.Image[[source]](../_modules/PIL/Image.html#Image)¶ This class represents an image object. To create `Image` objects, use the appropriate factory functions. There’s hardly ever any reason to call the Image constructor directly. * `open()` * `new()` * `frombytes()` An instance of the `Image` class has the following methods. Unless otherwise stated, all methods return a new instance of the `Image` class, holding the resulting image. Image.alpha_composite(_im : Image_, _dest : Sequence[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] = (0, 0)_, _source : Sequence[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] = (0, 0)_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.alpha_composite)¶ ‘In-place’ analog of Image.alpha_composite. Composites an image onto this image. Parameters: * **im** – image to composite over this one * **dest** – Optional 2 tuple (left, top) specifying the upper left corner in this (destination) image. * **source** – Optional 2 (left, top) tuple for the upper left corner in the overlay source image, or 4 tuple (left, top, right, bottom) for the bounds of the source rectangle Performance Note: Not currently implemented in-place in the core layer. Image.apply_transparency() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.apply_transparency)¶ If a P mode image has a “transparency” key in the info dictionary, remove the key and instead apply the transparency to the palette. Otherwise, the image is unchanged. Image.convert(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _matrix : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), ...] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _dither : Dither | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _palette : Palette = Palette.WEB_, _colors : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 256_) -> Image[[source]](../_modules/PIL/Image.html#Image.convert)¶ Returns a converted copy of this image. For the “P” mode, this method translates pixels through the palette. If mode is omitted, a mode is chosen so that all information in the image and the palette can be represented without a palette. This supports all possible conversions between “L”, “RGB” and “CMYK”. The `matrix` argument only supports “L” and “RGB”. When translating a color image to grayscale (mode “L”), the library uses the ITU-R 601-2 luma transform: L = R * 299/1000 + G * 587/1000 + B * 114/1000 The default method of converting a grayscale (“L”) or “RGB” image into a bilevel (mode “1”) image uses Floyd-Steinberg dither to approximate the original image luminosity levels. If dither is `None`, all values larger than 127 are set to 255 (white), all other values to 0 (black). To use other thresholds, use the `point()` method. When converting from “RGBA” to “P” without a `matrix` argument, this passes the operation to `quantize()`, and `dither` and `palette` are ignored. When converting from “PA”, if an “RGBA” palette is present, the alpha channel from the image will be used instead of the values from the palette. Parameters: * **mode** – The requested mode. See: [Modes](../handbook/concepts.html#concept-modes). * **matrix** – An optional conversion matrix. If given, this should be 4- or 12-tuple containing floating point values. * **dither** – Dithering method, used when converting from mode “RGB” to “P” or from “RGB” or “L” to “1”. Available methods are `Dither.NONE` or `Dither.FLOYDSTEINBERG` (default). Note that this is not used when `matrix` is supplied. * **palette** – Palette to use when converting from mode “RGB” to “P”. Available palettes are `Palette.WEB` or `Palette.ADAPTIVE`. * **colors** – Number of colors to use for the `Palette.ADAPTIVE` palette. Defaults to 256. Return type: `Image` Returns: An `Image` object. The following example converts an RGB image (linearly calibrated according to ITU-R 709, using the D65 luminant) to the CIE XYZ color space: rgb2xyz = ( 0.412453, 0.357580, 0.180423, 0, 0.212671, 0.715160, 0.072169, 0, 0.019334, 0.119193, 0.950227, 0) out = im.convert("RGB", rgb2xyz) Image.copy() -> Image[[source]](../_modules/PIL/Image.html#Image.copy)¶ Copies this image. Use this method if you wish to paste things into an image, but still retain the original. Return type: `Image` Returns: An `Image` object. Image.crop(_box : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> Image[[source]](../_modules/PIL/Image.html#Image.crop)¶ Returns a rectangular region from this image. The box is a 4-tuple defining the left, upper, right, and lower pixel coordinate. See [Coordinate system](../handbook/concepts.html#coordinate-system). Note: Prior to Pillow 3.4.0, this was a lazy operation. Parameters: **box** – The crop rectangle, as a (left, upper, right, lower)-tuple. Return type: `Image` Returns: An `Image` object. This crops the input image with the provided coordinates: from PIL import Image with Image.open("hopper.jpg") as im: # The crop method from the Image module takes four coordinates as input. # The right can also be represented as (left+width) # and lower can be represented as (upper+height). (left, upper, right, lower) = (20, 20, 100, 100) # Here the image "im" is cropped and assigned to new variable im_crop im_crop = im.crop((left, upper, right, lower)) Image.draft(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")_, _size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.draft)¶ Configures the image file loader so it returns a version of the image that as closely as possible matches the given mode and size. For example, you can use this method to convert a color JPEG to grayscale while loading it. If any changes are made, returns a tuple with the chosen `mode` and `box` with coordinates of the original image within the altered one. Note that this method modifies the `Image` object in place. If the image has already been loaded, this method has no effect. Note: This method is not implemented for most images. It is currently implemented only for JPEG and MPO images. Parameters: * **mode** – The requested mode. * **size** – The requested size in pixels, as a 2-tuple: (width, height). Image.effect_spread(_distance : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> Image[[source]](../_modules/PIL/Image.html#Image.effect_spread)¶ Randomly spread pixels in an image. Parameters: **distance** – Distance to spread pixels. Image.entropy(_mask : Image | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _extrema : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.entropy)¶ Calculates and returns the entropy for the image. A bilevel image (mode “1”) is treated as a grayscale (“L”) image by this method. If a mask is provided, the method employs the histogram for those parts of the image where the mask image is non-zero. The mask image must have the same size as the image, and be either a bi-level image (mode “1”) or a grayscale image (“L”). Parameters: * **mask** – An optional mask. * **extrema** – An optional tuple of manually-specified extrema. Returns: A float value representing the image entropy Image.filter(_filter : [ImageFilter.Filter](ImageFilter.html#PIL.ImageFilter.Filter "PIL.ImageFilter.Filter") | [type](https://docs.python.org/3/library/functions.html#type "\(in Python v3.14\)")[[ImageFilter.Filter](ImageFilter.html#PIL.ImageFilter.Filter "PIL.ImageFilter.Filter")]_) -> Image[[source]](../_modules/PIL/Image.html#Image.filter)¶ Filters this image using the given filter. For a list of available filters, see the [`ImageFilter`](ImageFilter.html#module-PIL.ImageFilter "PIL.ImageFilter") module. Parameters: **filter** – Filter kernel. Returns: An `Image` object. This blurs the input image using a filter from the `ImageFilter` module: from PIL import Image, ImageFilter with Image.open("hopper.jpg") as im: # Blur the input image using the filter ImageFilter.BLUR im_blurred = im.filter(filter=ImageFilter.BLUR) Image.frombytes(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [bytearray](https://docs.python.org/3/library/stdtypes.html#bytearray "\(in Python v3.14\)") | SupportsArrayInterface_, _decoder_name : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") = 'raw'_, _* args: Any_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.frombytes)¶ Loads this image with pixel data from a bytes object. This method is similar to the `frombytes()` function, but loads data into this image instead of creating a new image object. Image.getbands() -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), ...][[source]](../_modules/PIL/Image.html#Image.getbands)¶ Returns a tuple containing the name of each band in this image. For example, `getbands` on an RGB image returns (“R”, “G”, “B”). Returns: A tuple containing band names. Return type: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)") This helps to get the bands of the input image: from PIL import Image with Image.open("hopper.jpg") as im: print(im.getbands()) # Returns ('R', 'G', 'B') Image.getbbox(_*_ , _alpha_only : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = True_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.getbbox)¶ Calculates the bounding box of the non-zero regions in the image. Parameters: **alpha_only** – Optional flag, defaulting to `True`. If `True` and the image has an alpha channel, trim transparent pixels. Otherwise, trim pixels when all channels are zero. Keyword-only argument. Returns: The bounding box is returned as a 4-tuple defining the left, upper, right, and lower pixel coordinate. See [Coordinate system](../handbook/concepts.html#coordinate-system). If the image is completely empty, this method returns None. This helps to get the bounding box coordinates of the input image: from PIL import Image with Image.open("hopper.jpg") as im: print(im.getbbox()) # Returns four coordinates in the format (left, upper, right, lower) Image.getchannel(_channel : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> Image[[source]](../_modules/PIL/Image.html#Image.getchannel)¶ Returns an image containing a single channel of the source image. Parameters: **channel** – What channel to return. Could be index (0 for “R” channel of “RGB”) or channel name (“A” for alpha channel of “RGBA”). Returns: An image in “L” mode. Added in version 4.3.0. Image.getcolors(_maxcolors : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 256_) -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), ...]]] | [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.getcolors)¶ Returns a list of colors used in this image. The colors will be in the image’s mode. For example, an RGB image will return a tuple of (red, green, blue) color values, and a P image will return the index of the color in the palette. Parameters: **maxcolors** – Maximum number of colors. If this number is exceeded, this method returns None. The default limit is 256 colors. Returns: An unsorted list of (count, pixel) values. Image.getdata(_band : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [core.ImagingCore](internal_modules.html#PIL.Image.core.ImagingCore "PIL.Image.core.ImagingCore")[[source]](../_modules/PIL/Image.html#Image.getdata)¶ Returns the contents of this image as a sequence object containing pixel values. The sequence object is flattened, so that values for line one follow directly after the values of line zero, and so on. Note that the sequence object returned by this method is an internal PIL data type, which only supports certain sequence operations. To convert it to an ordinary sequence (e.g. for printing), use `list(im.getdata())`. Parameters: **band** – What band to return. The default is to return all bands. To return a single band, pass in the index value (e.g. 0 to get the “R” band from an “RGB” image). Returns: A sequence-like object. Image.getexif() -> Exif[[source]](../_modules/PIL/Image.html#Image.getexif)¶ Gets EXIF data from the image. Returns: an `Exif` object. Image.getextrema() -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")], ...][[source]](../_modules/PIL/Image.html#Image.getextrema)¶ Gets the minimum and maximum pixel values for each band in the image. Returns: For a single-band image, a 2-tuple containing the minimum and maximum pixel value. For a multi-band image, a tuple containing one 2-tuple for each band. Image.getpalette(_rawmode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = 'RGB'_) -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.getpalette)¶ Returns the image palette as a list. Parameters: **rawmode** – The mode in which to return the palette. `None` will return the palette in its current mode. Added in version 9.1.0. Returns: A list of color values [r, g, b, …], or None if the image has no palette. Image.getpixel(_xy : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_) -> [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), ...] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.getpixel)¶ Returns the pixel value at a given position. Parameters: **xy** – The coordinate, given as (x, y). See [Coordinate system](../handbook/concepts.html#coordinate-system). Returns: The pixel value. If the image is a multi-layer image, this method returns a tuple. Image.getprojection() -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")], [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]][[source]](../_modules/PIL/Image.html#Image.getprojection)¶ Get projection to x and y axes Returns: Two sequences, indicating where there are non-zero pixels along the X-axis and the Y-axis, respectively. Image.getxmp() -> [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), Any][[source]](../_modules/PIL/Image.html#Image.getxmp)¶ Returns a dictionary containing the XMP tags. Requires defusedxml to be installed. Returns: XMP tags in a dictionary. Image.histogram(_mask : Image | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _extrema : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/Image.html#Image.histogram)¶ Returns a histogram for the image. The histogram is returned as a list of pixel counts, one for each pixel value in the source image. Counts are grouped into 256 bins for each band, even if the image has more than 8 bits per band. If the image has more than one band, the histograms for all bands are concatenated (for example, the histogram for an “RGB” image contains 768 values). A bilevel image (mode “1”) is treated as a grayscale (“L”) image by this method. If a mask is provided, the method returns a histogram for those parts of the image where the mask image is non-zero. The mask image must have the same size as the image, and be either a bi-level image (mode “1”) or a grayscale image (“L”). Parameters: * **mask** – An optional mask. * **extrema** – An optional tuple of manually-specified extrema. Returns: A list containing pixel counts. Image.paste(_im : Image | [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), ...]_, _box : Image | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _mask : Image | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.paste)¶ Pastes another image into this image. The box argument is either a 2-tuple giving the upper left corner, a 4-tuple defining the left, upper, right, and lower pixel coordinate, or None (same as (0, 0)). See [Coordinate system](../handbook/concepts.html#coordinate-system). If a 4-tuple is given, the size of the pasted image must match the size of the region. If the modes don’t match, the pasted image is converted to the mode of this image (see the `convert()` method for details). Instead of an image, the source can be a integer or tuple containing pixel values. The method then fills the region with the given color. When creating RGB images, you can also use color strings as supported by the ImageColor module. See [Colors](../handbook/concepts.html#colors) for more information. If a mask is given, this method updates only the regions indicated by the mask. You can use either “1”, “L”, “LA”, “RGBA” or “RGBa” images (if present, the alpha band is used as mask). Where the mask is 255, the given image is copied as is. Where the mask is 0, the current value is preserved. Intermediate values will mix the two images together, including their alpha channels if they have them. See `alpha_composite()` if you want to combine images with respect to their alpha channels. Parameters: * **im** – Source image or pixel value (integer, float or tuple). * **box** – An optional 4-tuple giving the region to paste into. If a 2-tuple is used instead, it’s treated as the upper left corner. If omitted or None, the source is pasted into the upper left corner. If an image is given as the second argument and there is no third, the box defaults to (0, 0), and the second argument is interpreted as a mask image. * **mask** – An optional mask image. Image.point(_lut : Sequence[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] | [NumpyArray](internal_modules.html#PIL._typing.NumpyArray "PIL._typing.NumpyArray") | Callable[[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")], [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] | Callable[[ImagePointTransform], ImagePointTransform | [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] | ImagePointHandler_, _mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> Image[[source]](../_modules/PIL/Image.html#Image.point)¶ Maps this image through a lookup table or function. Parameters: * **lut** – A lookup table, containing 256 (or 65536 if self.mode==”I” and mode == “L”) values per band in the image. A function can be used instead, it should take a single argument. The function is called once for each possible pixel value, and the resulting table is applied to all bands of the image. It may also be an `ImagePointHandler` object: class Example(Image.ImagePointHandler): def point(self, im: Image) -> Image: # Return result * **mode** – Output mode (default is same as input). This can only be used if the source image has mode “L” or “P”, and the output has mode “1” or the source image mode is “I” and the output mode is “L”. Returns: An `Image` object. Image.putalpha(_alpha : Image | [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.putalpha)¶ Adds or replaces the alpha layer in this image. If the image does not have an alpha layer, it’s converted to “LA” or “RGBA”. The new layer must be either “L” or “1”. Parameters: **alpha** – The new alpha layer. This can either be an “L” or “1” image having the same size as this image, or an integer. Image.putdata(_data : Sequence[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] | Sequence[Sequence[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]] | [core.ImagingCore](internal_modules.html#PIL.Image.core.ImagingCore "PIL.Image.core.ImagingCore") | [NumpyArray](internal_modules.html#PIL._typing.NumpyArray "PIL._typing.NumpyArray")_, _scale : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") = 1.0_, _offset : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") = 0.0_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.putdata)¶ Copies pixel data from a flattened sequence object into the image. The values should start at the upper left corner (0, 0), continue to the end of the line, followed directly by the first value of the second line, and so on. Data will be read until either the image or the sequence ends. The scale and offset values are used to adjust the sequence values: **pixel = value*scale + offset**. Parameters: * **data** – A flattened sequence object. See [Colors](../handbook/concepts.html#colors) for more information about values. * **scale** – An optional scale value. The default is 1.0. * **offset** – An optional offset value. The default is 0.0. Image.putpalette(_data : [ImagePalette.ImagePalette](ImagePalette.html#PIL.ImagePalette.ImagePalette "PIL.ImagePalette.ImagePalette") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | Sequence[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _rawmode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") = 'RGB'_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.putpalette)¶ Attaches a palette to this image. The image must be a “P”, “PA”, “L” or “LA” image. The palette sequence must contain at most 256 colors, made up of one integer value for each channel in the raw mode. For example, if the raw mode is “RGB”, then it can contain at most 768 values, made up of red, green and blue values for the corresponding pixel index in the 256 colors. If the raw mode is “RGBA”, then it can contain at most 1024 values, containing red, green, blue and alpha values. Alternatively, an 8-bit string may be used instead of an integer sequence. Parameters: * **data** – A palette sequence (either a list or a string). * **rawmode** – The raw mode of the palette. Either “RGB”, “RGBA”, or a mode that can be transformed to “RGB” or “RGBA” (e.g. “R”, “BGR;15”, “RGBA;L”). Image.putpixel(_xy : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _value : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), ...] | [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.putpixel)¶ Modifies the pixel at the given position. The color is given as a single numerical value for single-band images, and a tuple for multi-band images. In addition to this, RGB and RGBA tuples are accepted for P and PA images. See [Colors](../handbook/concepts.html#colors) for more information. Note that this method is relatively slow. For more extensive changes, use `paste()` or the [`ImageDraw`](ImageDraw.html#module-PIL.ImageDraw "PIL.ImageDraw") module instead. See: * `paste()` * `putdata()` * [`ImageDraw`](ImageDraw.html#module-PIL.ImageDraw "PIL.ImageDraw") Parameters: * **xy** – The pixel coordinate, given as (x, y). See [Coordinate system](../handbook/concepts.html#coordinate-system). * **value** – The pixel value. Image.quantize(_colors : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 256_, _method : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _kmeans : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 0_, _palette : Image | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _dither : Dither = Dither.FLOYDSTEINBERG_) -> Image[[source]](../_modules/PIL/Image.html#Image.quantize)¶ Convert the image to ‘P’ mode with the specified number of colors. Parameters: * **colors** – The desired number of colors, <= 256 * **method** – `Quantize.MEDIANCUT` (median cut), `Quantize.MAXCOVERAGE` (maximum coverage), `Quantize.FASTOCTREE` (fast octree), `Quantize.LIBIMAGEQUANT` (libimagequant; check support using [`PIL.features.check_feature()`](features.html#PIL.features.check_feature "PIL.features.check_feature") with `feature="libimagequant"`). By default, `Quantize.MEDIANCUT` will be used. The exception to this is RGBA images. `Quantize.MEDIANCUT` and `Quantize.MAXCOVERAGE` do not support RGBA images, so `Quantize.FASTOCTREE` is used by default instead. * **kmeans** – Integer greater than or equal to zero. * **palette** – Quantize to the palette of given `PIL.Image.Image`. * **dither** – Dithering method, used when converting from mode “RGB” to “P” or from “RGB” or “L” to “1”. Available methods are `Dither.NONE` or `Dither.FLOYDSTEINBERG` (default). Returns: A new image Image.reduce(_factor : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _box : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> Image[[source]](../_modules/PIL/Image.html#Image.reduce)¶ Returns a copy of the image reduced `factor` times. If the size of the image is not dividable by `factor`, the resulting size will be rounded up. Parameters: * **factor** – A greater than 0 integer or tuple of two integers for width and height separately. * **box** – An optional 4-tuple of ints providing the source image region to be reduced. The values must be within `(0, 0, width, height)` rectangle. If omitted or `None`, the entire source is used. Image.remap_palette(_dest_map : [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _source_palette : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [bytearray](https://docs.python.org/3/library/stdtypes.html#bytearray "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> Image[[source]](../_modules/PIL/Image.html#Image.remap_palette)¶ Rewrites the image to reorder the palette. Parameters: * **dest_map** – A list of indexes into the original palette. e.g. `[1,0]` would swap a two item palette, and `list(range(256))` is the identity transform. * **source_palette** – Bytes or None. Returns: An `Image` object. Image.resize(_size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [NumpyArray](internal_modules.html#PIL._typing.NumpyArray "PIL._typing.NumpyArray")_, _resample : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _box : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _reducing_gap : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> Image[[source]](../_modules/PIL/Image.html#Image.resize)¶ Returns a resized copy of this image. Parameters: * **size** – The requested size in pixels, as a tuple or array: (width, height). * **resample** – An optional resampling filter. This can be one of `Resampling.NEAREST`, `Resampling.BOX`, `Resampling.BILINEAR`, `Resampling.HAMMING`, `Resampling.BICUBIC` or `Resampling.LANCZOS`. If the image has mode “1” or “P”, it is always set to `Resampling.NEAREST`. Otherwise, the default filter is `Resampling.BICUBIC`. See: [Filters](../handbook/concepts.html#concept-filters). * **box** – An optional 4-tuple of floats providing the source image region to be scaled. The values must be within (0, 0, width, height) rectangle. If omitted or None, the entire source is used. * **reducing_gap** – Apply optimization by resizing the image in two steps. First, reducing the image by integer times using `reduce()`. Second, resizing using regular resampling. The last step changes size no less than by `reducing_gap` times. `reducing_gap` may be None (no first step is performed) or should be greater than 1.0. The bigger `reducing_gap`, the closer the result to the fair resampling. The smaller `reducing_gap`, the faster resizing. With `reducing_gap` greater or equal to 3.0, the result is indistinguishable from fair resampling in most cases. The default value is None (no optimization). Returns: An `Image` object. This resizes the given image from `(width, height)` to `(width/2, height/2)`: from PIL import Image with Image.open("hopper.jpg") as im: # Provide the target width and height of the image (width, height) = (im.width // 2, im.height // 2) im_resized = im.resize((width, height)) Image.rotate(_angle : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")_, _resample : Resampling = Resampling.NEAREST_, _expand : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = False_, _center : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _translate : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _fillcolor : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), ...] | [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> Image[[source]](../_modules/PIL/Image.html#Image.rotate)¶ Returns a rotated copy of this image. This method returns a copy of this image, rotated the given number of degrees counter clockwise around its centre. Parameters: * **angle** – In degrees counter clockwise. * **resample** – An optional resampling filter. This can be one of `Resampling.NEAREST` (use nearest neighbour), `Resampling.BILINEAR` (linear interpolation in a 2x2 environment), or `Resampling.BICUBIC` (cubic spline interpolation in a 4x4 environment). If omitted, or if the image has mode “1” or “P”, it is set to `Resampling.NEAREST`. See [Filters](../handbook/concepts.html#concept-filters). * **expand** – Optional expansion flag. If true, expands the output image to make it large enough to hold the entire rotated image. If false or omitted, make the output image the same size as the input image. Note that the expand flag assumes rotation around the center and no translation. * **center** – Optional center of rotation (a 2-tuple). Origin is the upper left corner. Default is the center of the image. * **translate** – An optional post-rotate translation (a 2-tuple). * **fillcolor** – An optional color for area outside the rotated image. Returns: An `Image` object. This rotates the input image by `theta` degrees counter clockwise: from PIL import Image with Image.open("hopper.jpg") as im: # Rotate the image by 60 degrees counter clockwise theta = 60 # Angle is in degrees counter clockwise im_rotated = im.rotate(angle=theta) Image.save(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _format : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _** params: Any_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.save)¶ Saves this image under the given filename. If no format is specified, the format to use is determined from the filename extension, if possible. Keyword options can be used to provide additional instructions to the writer. If a writer doesn’t recognise an option, it is silently ignored. The available options are described in the [image format documentation](../handbook/image- file-formats.html) for each writer. You can use a file object instead of a filename. In this case, you must always specify the format. The file object must implement the `seek`, `tell`, and `write` methods, and be opened in binary mode. Parameters: * **fp** – A filename (string), os.PathLike object or file object. * **format** – Optional format override. If omitted, the format to use is determined from the filename extension. If a file object was used instead of a filename, this parameter should always be used. * **params** – Extra parameters to the image writer. These can also be set on the image itself through `encoderinfo`. This is useful when saving multiple images: # Saving XMP data to a single image from PIL import Image red = Image.new("RGB", (1, 1), "#f00") red.save("out.mpo", xmp=b"test") # Saving XMP data to the second frame of an image from PIL import Image black = Image.new("RGB", (1, 1)) red = Image.new("RGB", (1, 1), "#f00") red.encoderinfo = {"xmp": b"test"} black.save("out.mpo", save_all=True, append_images=[red]) Returns: None Raises: * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "\(in Python v3.14\)") – If the output format could not be determined from the file name. Use the format option to solve this. * [**OSError**](https://docs.python.org/3/library/exceptions.html#OSError "\(in Python v3.14\)") – If the file could not be written. The file may have been created, and may contain partial data. Image.seek(_frame : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.seek)¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an `EOFError` exception. When a sequence file is opened, the library automatically seeks to frame 0. See `tell()`. If defined, `n_frames` refers to the number of available frames. Parameters: **frame** – Frame number, starting at 0. Raises: [**EOFError**](https://docs.python.org/3/library/exceptions.html#EOFError "\(in Python v3.14\)") – If the call attempts to seek beyond the end of the sequence. Image.show(_title : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.show)¶ Displays this image. This method is mainly intended for debugging purposes. This method calls [`PIL.ImageShow.show()`](ImageShow.html#PIL.ImageShow.show "PIL.ImageShow.show") internally. You can use [`PIL.ImageShow.register()`](ImageShow.html#PIL.ImageShow.register "PIL.ImageShow.register") to override its default behaviour. The image is first saved to a temporary file. By default, it will be in PNG format. On Unix, the image is then opened using the **xdg-open** , **display** , **gm** , **eog** or **xv** utility, depending on which one can be found. On macOS, the image is opened with the native Preview application. On Windows, the image is opened with the standard PNG display utility. Parameters: **title** – Optional title to use for the image window, where possible. Image.split() -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[Image, ...][[source]](../_modules/PIL/Image.html#Image.split)¶ Split this image into individual bands. This method returns a tuple of individual image bands from an image. For example, splitting an “RGB” image creates three new images each containing a copy of one of the original bands (red, green, blue). If you need only one band, `getchannel()` method can be more convenient and faster. Returns: A tuple containing bands. Image.tell() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.tell)¶ Returns the current frame number. See `seek()`. If defined, `n_frames` refers to the number of available frames. Returns: Frame number, starting with 0. Image.thumbnail(_size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]_, _resample : Resampling = Resampling.BICUBIC_, _reducing_gap : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = 2.0_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.thumbnail)¶ Make this image into a thumbnail. This method modifies the image to contain a thumbnail version of itself, no larger than the given size. This method calculates an appropriate thumbnail size to preserve the aspect of the image, calls the `draft()` method to configure the file reader (where applicable), and finally resizes the image. Note that this function modifies the `Image` object in place. If you need to use the full resolution image as well, apply this method to a `copy()` of the original image. Parameters: * **size** – The requested size in pixels, as a 2-tuple: (width, height). * **resample** – Optional resampling filter. This can be one of `Resampling.NEAREST`, `Resampling.BOX`, `Resampling.BILINEAR`, `Resampling.HAMMING`, `Resampling.BICUBIC` or `Resampling.LANCZOS`. If omitted, it defaults to `Resampling.BICUBIC`. (was `Resampling.NEAREST` prior to version 2.5.0). See: [Filters](../handbook/concepts.html#concept-filters). * **reducing_gap** – Apply optimization by resizing the image in two steps. First, reducing the image by integer times using `reduce()` or `draft()` for JPEG images. Second, resizing using regular resampling. The last step changes size no less than by `reducing_gap` times. `reducing_gap` may be None (no first step is performed) or should be greater than 1.0. The bigger `reducing_gap`, the closer the result to the fair resampling. The smaller `reducing_gap`, the faster resizing. With `reducing_gap` greater or equal to 3.0, the result is indistinguishable from fair resampling in most cases. The default value is 2.0 (very close to fair resampling while still being faster in many cases). Returns: None Image.tobitmap(_name : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") = 'image'_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.tobitmap)¶ Returns the image converted to an X11 bitmap. Note This method only works for mode “1” images. Parameters: **name** – The name prefix to use for the bitmap variables. Returns: A string containing an X11 bitmap. Raises: [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "\(in Python v3.14\)") – If the mode is not “1” Image.tobytes(_encoder_name : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") = 'raw'_, _* args: Any_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.tobytes)¶ Return image as a bytes object. Warning This method returns raw image data derived from Pillow’s internal storage. For compressed image data (e.g. PNG, JPEG) use `save()`, with a BytesIO parameter for in-memory data. Parameters: * **encoder_name** – What encoder to use. The default is to use the standard “raw” encoder. To see how this packs pixel data into the returned bytes, see `libImaging/Pack.c`. A list of C encoders can be seen under codecs section of the function array in `_imaging.c`. Python encoders are registered within the relevant plugins. * **args** – Extra arguments to the encoder. Returns: A [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") object. Image.transform(_size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _method : Transform | ImageTransformHandler | SupportsGetData_, _data : Sequence[Any] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _resample : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = Resampling.NEAREST_, _fill : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 1_, _fillcolor : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), ...] | [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> Image[[source]](../_modules/PIL/Image.html#Image.transform)¶ Transforms this image. This method creates a new image with the given size, and the same mode as the original, and copies data to the new image using the given transform. Parameters: * **size** – The output size in pixels, as a 2-tuple: (width, height). * **method** – The transformation method. This is one of `Transform.EXTENT` (cut out a rectangular subregion), `Transform.AFFINE` (affine transform), `Transform.PERSPECTIVE` (perspective transform), `Transform.QUAD` (map a quadrilateral to a rectangle), or `Transform.MESH` (map a number of source quadrilaterals in one operation). It may also be an `ImageTransformHandler` object: class Example(Image.ImageTransformHandler): def transform(self, size, data, resample, fill=1): # Return result Implementations of `ImageTransformHandler` for some of the `Transform` methods are provided in [`ImageTransform`](ImageTransform.html#module- PIL.ImageTransform "PIL.ImageTransform"). It may also be an object with a `method.getdata` method that returns a tuple supplying new `method` and `data` values: class Example: def getdata(self): method = Image.Transform.EXTENT data = (0, 0, 100, 100) return method, data * **data** – Extra data to the transformation method. * **resample** – Optional resampling filter. It can be one of `Resampling.NEAREST` (use nearest neighbour), `Resampling.BILINEAR` (linear interpolation in a 2x2 environment), or `Resampling.BICUBIC` (cubic spline interpolation in a 4x4 environment). If omitted, or if the image has mode “1” or “P”, it is set to `Resampling.NEAREST`. See: [Filters](../handbook/concepts.html#concept-filters). * **fill** – If `method` is an `ImageTransformHandler` object, this is one of the arguments passed to it. Otherwise, it is unused. * **fillcolor** – Optional fill color for the area outside the transform in the output image. Returns: An `Image` object. Image.transpose(_method : Transpose_) -> Image[[source]](../_modules/PIL/Image.html#Image.transpose)¶ Transpose image (flip or rotate in 90 degree steps) Parameters: **method** – One of `Transpose.FLIP_LEFT_RIGHT`, `Transpose.FLIP_TOP_BOTTOM`, `Transpose.ROTATE_90`, `Transpose.ROTATE_180`, `Transpose.ROTATE_270`, `Transpose.TRANSPOSE` or `Transpose.TRANSVERSE`. Returns: Returns a flipped or rotated copy of this image. This flips the input image by using the `Transpose.FLIP_LEFT_RIGHT` method. from PIL import Image with Image.open("hopper.jpg") as im: # Flip the image from left to right im_flipped = im.transpose(method=Image.Transpose.FLIP_LEFT_RIGHT) # To flip the image from top to bottom, # use the method "Image.Transpose.FLIP_TOP_BOTTOM" Image.verify() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.verify)¶ Verifies the contents of a file. For data read from a file, this method attempts to determine if the file is broken, without actually decoding the image data. If this method finds any problems, it raises suitable exceptions. If you need to load the image after using this method, you must reopen the image file. Image.load() -> [core.PixelAccess](PixelAccess.html#PixelAccess "PIL.Image.core.PixelAccess") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.load)¶ Allocates storage for the image and loads the pixel data. In normal cases, you don’t need to call this method, since the Image class automatically loads an opened image when it is accessed for the first time. If the file associated with the image was opened by Pillow, then this method will close it. The exception to this is if the image has multiple frames, in which case the file will be left open for seek operations. See [File handling in Pillow](open_files.html#file-handling) for more information. Returns: An image access object. Return type: [`PixelAccess`](PixelAccess.html#PixelAccess "PixelAccess") Image.close() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Image.close)¶ This operation will destroy the image core and release its memory. The image data will be unusable afterward. This function is required to close images that have multiple frames or have not had their file read and closed by the `load()` method. See [File handling in Pillow](open_files.html#file-handling) for more information. ## Image attributes¶ Instances of the `Image` class have the following attributes: Image.filename: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")¶ The filename or path of the source file. Only images created with the factory function `open` have a filename attribute. If the input is a file like object, the filename attribute is set to an empty string. Image.format: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ The file format of the source file. For images created by the library itself (via a factory function, or by running a method on an existing image), this attribute is set to [`None`](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)"). Image.mode: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")¶ Image mode. This is a string specifying the pixel format used by the image. Typical values are “1”, “L”, “RGB”, or “CMYK.” See [Modes](../handbook/concepts.html#concept-modes) for a full list. Image.size: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]¶ Image size, in pixels. The size is given as a 2-tuple (width, height). Image.width: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ Image width, in pixels. Image.height: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ Image height, in pixels. Image.palette: [PIL.ImagePalette.ImagePalette](ImagePalette.html#PIL.ImagePalette.ImagePalette "PIL.ImagePalette.ImagePalette") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ Colour palette table, if any. If mode is “P” or “PA”, this should be an instance of the [`ImagePalette`](ImagePalette.html#PIL.ImagePalette.ImagePalette "PIL.ImagePalette.ImagePalette") class. Otherwise, it should be set to [`None`](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)"). Image.info: [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")¶ A dictionary holding data associated with the image. This dictionary is used by file handlers to pass on various non-image information read from the file. See documentation for the various file handlers for details. Most methods ignore the dictionary when returning new images; since the keys are not standardized, it’s not possible for a method to know if the operation affects the dictionary. If you need the information later on, keep a reference to the info dictionary returned from the open method. Unless noted elsewhere, this dictionary does not affect saving files. Image.is_animated: [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)")¶ `True` if this image has more than one frame, or `False` otherwise. This attribute is only defined by image plugins that support animated images. Plugins may leave this attribute undefined if they don’t support loading animated images, even if the given format supports animated images. Given that this attribute is not present for all images use `getattr(image, "is_animated", False)` to check if Pillow is aware of multiple frames in an image regardless of its format. See also `n_frames`, `seek()` and `tell()` Image.n_frames: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ The number of frames in this image. This attribute is only defined by image plugins that support animated images. Plugins may leave this attribute undefined if they don’t support loading animated images, even if the given format supports animated images. Given that this attribute is not present for all images use `getattr(image, "n_frames", 1)` to check the number of frames that Pillow is aware of in an image regardless of its format. See also `is_animated`, `seek()` and `tell()` Image.has_transparency_data¶ Determine if an image has transparency data, whether in the form of an alpha channel, a palette with an alpha channel, or a “transparency” key in the info dictionary. Note the image might still appear solid, if all of the values shown within are opaque. Returns: A boolean. ## Classes¶ class PIL.Image.Exif[[source]](../_modules/PIL/Image.html#Exif)¶ Bases: [`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping "\(in Python v3.14\)") This class provides read and write access to EXIF image data: from PIL import Image im = Image.open("exif.png") exif = im.getexif() # Returns an instance of this class Information can be read and written, iterated over or deleted: print(exif[274]) # 1 exif[274] = 2 for k, v in exif.items(): print("Tag", k, "Value", v) # Tag 274 Value 2 del exif[274] To access information beyond IFD0, `get_ifd()` returns a dictionary: from PIL import ExifTags im = Image.open("exif_gps.jpg") exif = im.getexif() gps_ifd = exif.get_ifd(ExifTags.IFD.GPSInfo) print(gps_ifd) Other IFDs include `ExifTags.IFD.Exif`, `ExifTags.IFD.MakerNote`, `ExifTags.IFD.Interop` and `ExifTags.IFD.IFD1`. [`ExifTags`](ExifTags.html#module-PIL.ExifTags "PIL.ExifTags") also has enum classes to provide names for data: print(exif[ExifTags.Base.Software]) # PIL print(gps_ifd[ExifTags.GPS.GPSDateStamp]) # 1999:99:99 99:99:99 bigtiff = False¶ endian: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None¶ get_ifd(_tag : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), Any][[source]](../_modules/PIL/Image.html#Exif.get_ifd)¶ hide_offsets() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Exif.hide_offsets)¶ load(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Exif.load)¶ load_from_fp(_fp : [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _offset : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Exif.load_from_fp)¶ tobytes(_offset : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 8_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/Image.html#Exif.tobytes)¶ class PIL.Image.ImagePointHandler[[source]](../_modules/PIL/Image.html#ImagePointHandler)¶ Used as a mixin by point transforms (for use with `point()`) class PIL.Image.ImagePointTransform(_scale : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")_, _offset : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")_)[[source]](../_modules/PIL/Image.html#ImagePointTransform)¶ Used with `point()` for single band images with more than 8 bits, this represents an affine transformation, where the value is multiplied by `scale` and `offset` is added. class PIL.Image.ImageTransformHandler[[source]](../_modules/PIL/Image.html#ImageTransformHandler)¶ Used as a mixin by geometry transforms (for use with `transform()`) ## Protocols¶ class PIL.Image.SupportsArrayInterface(_* args_, _** kwargs_)[[source]](../_modules/PIL/Image.html#SupportsArrayInterface)¶ Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol "\(in Python v3.14\)") An object that has an `__array_interface__` dictionary. class PIL.Image.SupportsArrowArrayInterface(_* args_, _** kwargs_)[[source]](../_modules/PIL/Image.html#SupportsArrowArrayInterface)¶ Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol "\(in Python v3.14\)") An object that has an `__arrow_c_array__` method corresponding to the arrow c data interface. class PIL.Image.SupportsGetData(_* args_, _** kwargs_)[[source]](../_modules/PIL/Image.html#SupportsGetData)¶ Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol "\(in Python v3.14\)") ## Constants¶ PIL.Image.NONE¶ PIL.Image.MAX_IMAGE_PIXELS¶ Set to 89,478,485, approximately 0.25GB for a 24-bit (3 bpp) image. See `open()` for more information about how this is used. PIL.Image.WARN_POSSIBLE_FORMATS¶ Set to false. If true, when an image cannot be identified, warnings will be raised from formats that attempted to read the data. ### Transpose methods¶ Used to specify the `Image.transpose()` method to use. class PIL.Image.Transpose(_* values_)[[source]](../_modules/PIL/Image.html#Transpose)¶ FLIP_LEFT_RIGHT = 0¶ FLIP_TOP_BOTTOM = 1¶ ROTATE_180 = 3¶ ROTATE_270 = 4¶ ROTATE_90 = 2¶ TRANSPOSE = 5¶ TRANSVERSE = 6¶ ### Transform methods¶ Used to specify the `Image.transform()` method to use. class PIL.Image.Transform[[source]](../_modules/PIL/Image.html#Transform)¶ AFFINE¶ Affine transform EXTENT¶ Cut out a rectangular subregion PERSPECTIVE¶ Perspective transform QUAD¶ Map a quadrilateral to a rectangle MESH¶ Map a number of source quadrilaterals in one operation ### Resampling filters¶ See [Filters](../handbook/concepts.html#concept-filters) for details. class PIL.Image.Resampling(_* values_)[[source]](../_modules/PIL/Image.html#Resampling)¶ BICUBIC = 3¶ BILINEAR = 2¶ BOX = 4¶ HAMMING = 5¶ LANCZOS = 1¶ NEAREST = 0¶ ### Dither modes¶ Used to specify the dithering method to use for the `convert()` and `quantize()` methods. class PIL.Image.Dither[[source]](../_modules/PIL/Image.html#Dither)¶ NONE¶ No dither ORDERED¶ Not implemented RASTERIZE¶ Not implemented FLOYDSTEINBERG¶ Floyd-Steinberg dither ### Palettes¶ Used to specify the palette to use for the `convert()` method. class PIL.Image.Palette(_* values_)[[source]](../_modules/PIL/Image.html#Palette)¶ ADAPTIVE = 1¶ WEB = 0¶ ### Quantization methods¶ Used to specify the quantization method to use for the `quantize()` method. class PIL.Image.Quantize[[source]](../_modules/PIL/Image.html#Quantize)¶ MEDIANCUT¶ Median cut. Default method, except for RGBA images. This method does not support RGBA images. MAXCOVERAGE¶ Maximum coverage. This method does not support RGBA images. FASTOCTREE¶ Fast octree. Default method for RGBA images. LIBIMAGEQUANT¶ libimagequant Check support using [`PIL.features.check_feature()`](features.html#PIL.features.check_feature "PIL.features.check_feature") with `feature="libimagequant"`. [ Next `ImageChops` (“channel operations”) module ](ImageChops.html) [ Previous Reference ](index.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `Image` module * Examples * Open, rotate, and display an image (using the default viewer) * Create thumbnails * Functions * `open()` * Image processing * `alpha_composite()` * `blend()` * `composite()` * `eval()` * `merge()` * Constructing images * `new()` * `fromarray()` * `fromarrow()` * `frombytes()` * `frombuffer()` * Generating images * `effect_mandelbrot()` * `effect_noise()` * `linear_gradient()` * `radial_gradient()` * Registering plugins * `preinit()` * `init()` * `register_open()` * `register_mime()` * `register_save()` * `register_save_all()` * `register_extension()` * `register_extensions()` * `registered_extensions()` * `register_decoder()` * `register_encoder()` * The Image class * `Image` * `Image.alpha_composite()` * `Image.apply_transparency()` * `Image.convert()` * `Image.copy()` * `Image.crop()` * `Image.draft()` * `Image.effect_spread()` * `Image.entropy()` * `Image.filter()` * `Image.frombytes()` * `Image.getbands()` * `Image.getbbox()` * `Image.getchannel()` * `Image.getcolors()` * `Image.getdata()` * `Image.getexif()` * `Image.getextrema()` * `Image.getpalette()` * `Image.getpixel()` * `Image.getprojection()` * `Image.getxmp()` * `Image.histogram()` * `Image.paste()` * `Image.point()` * `Image.putalpha()` * `Image.putdata()` * `Image.putpalette()` * `Image.putpixel()` * `Image.quantize()` * `Image.reduce()` * `Image.remap_palette()` * `Image.resize()` * `Image.rotate()` * `Image.save()` * `Image.seek()` * `Image.show()` * `Image.split()` * `Image.tell()` * `Image.thumbnail()` * `Image.tobitmap()` * `Image.tobytes()` * `Image.transform()` * `Image.transpose()` * `Image.verify()` * `Image.load()` * `Image.close()` * Image attributes * `Image.filename` * `Image.format` * `Image.mode` * `Image.size` * `Image.width` * `Image.height` * `Image.palette` * `Image.info` * `Image.is_animated` * `Image.n_frames` * `Image.has_transparency_data` * Classes * `Exif` * `Exif.bigtiff` * `Exif.endian` * `Exif.get_ifd()` * `Exif.hide_offsets()` * `Exif.load()` * `Exif.load_from_fp()` * `Exif.tobytes()` * `ImagePointHandler` * `ImagePointTransform` * `ImageTransformHandler` * Protocols * `SupportsArrayInterface` * `SupportsArrowArrayInterface` * `SupportsGetData` * Constants * `NONE` * `MAX_IMAGE_PIXELS` * `WARN_POSSIBLE_FORMATS` * Transpose methods * `Transpose` * `Transpose.FLIP_LEFT_RIGHT` * `Transpose.FLIP_TOP_BOTTOM` * `Transpose.ROTATE_180` * `Transpose.ROTATE_270` * `Transpose.ROTATE_90` * `Transpose.TRANSPOSE` * `Transpose.TRANSVERSE` * Transform methods * `Transform` * `Transform.AFFINE` * `Transform.EXTENT` * `Transform.PERSPECTIVE` * `Transform.QUAD` * `Transform.MESH` * Resampling filters * `Resampling` * `Resampling.BICUBIC` * `Resampling.BILINEAR` * `Resampling.BOX` * `Resampling.HAMMING` * `Resampling.LANCZOS` * `Resampling.NEAREST` * Dither modes * `Dither` * `Dither.NONE` * `Dither.ORDERED` * `Dither.RASTERIZE` * `Dither.FLOYDSTEINBERG` * Palettes * `Palette` * `Palette.ADAPTIVE` * `Palette.WEB` * Quantization methods * `Quantize` * `Quantize.MEDIANCUT` * `Quantize.MAXCOVERAGE` * `Quantize.FASTOCTREE` * `Quantize.LIBIMAGEQUANT` *[*]: Keyword-only parameters separator (PEP 3102) --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImageChops.html # Path: reference/ImageChops.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * `ImageChops` (“channel operations”) module * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImageChops.rst.txt "View this page") # `ImageChops` (“channel operations”) module¶ The `ImageChops` module contains a number of arithmetical image operations, called channel operations (“chops”). These can be used for various purposes, including special effects, image compositions, algorithmic painting, and more. For more pre-made operations, see [`ImageOps`](ImageOps.html#module- PIL.ImageOps "PIL.ImageOps"). At this time, most channel operations are only implemented for 8-bit images (e.g. “L” and “RGB”). ## Functions¶ Most channel operations take one or two image arguments and returns a new image. Unless otherwise noted, the result of a channel operation is always clipped to the range 0 to MAX (which is 255 for all modes supported by the operations in this module). PIL.ImageChops.add(_image1 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _image2 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _scale : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") = 1.0_, _offset : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") = 0_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#add)¶ Adds two images, dividing the result by scale and adding the offset. If omitted, scale defaults to 1.0, and offset to 0.0. out = ((image1 + image2) / scale + offset) Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.add_modulo(_image1 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _image2 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#add_modulo)¶ Add two images, without clipping the result. out = ((image1 + image2) % MAX) Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.blend(_image1 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _image2 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _alpha : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#blend)¶ Blend images using constant transparency weight. Alias for [`PIL.Image.blend()`](Image.html#PIL.Image.blend "PIL.Image.blend"). Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.composite(_image1 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _image2 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _mask : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#composite)¶ Create composite using transparency mask. Alias for [`PIL.Image.composite()`](Image.html#PIL.Image.composite "PIL.Image.composite"). Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.constant(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _value : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#constant)¶ Fill a channel with a given gray level. Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.darker(_image1 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _image2 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#darker)¶ Compares the two images, pixel by pixel, and returns a new image containing the darker values. out = min(image1, image2) Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.difference(_image1 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _image2 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#difference)¶ Returns the absolute value of the pixel-by-pixel difference between the two images. out = abs(image1 - image2) Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.duplicate(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#duplicate)¶ Copy a channel. Alias for [`PIL.Image.Image.copy()`](Image.html#PIL.Image.Image.copy "PIL.Image.Image.copy"). Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.invert(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#invert)¶ Invert an image (channel). out = MAX - image Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.lighter(_image1 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _image2 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#lighter)¶ Compares the two images, pixel by pixel, and returns a new image containing the lighter values. out = max(image1, image2) Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.logical_and(_image1 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _image2 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#logical_and)¶ Logical AND between two images. Both of the images must have mode “1”. If you would like to perform a logical AND on an image with a mode other than “1”, try `multiply()` instead, using a black-and-white mask as the second image. out = ((image1 and image2) % MAX) Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.logical_or(_image1 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _image2 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#logical_or)¶ Logical OR between two images. Both of the images must have mode “1”. out = ((image1 or image2) % MAX) Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.logical_xor(_image1 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _image2 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#logical_xor)¶ Logical XOR between two images. Both of the images must have mode “1”. out = ((bool(image1) != bool(image2)) % MAX) Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.multiply(_image1 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _image2 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#multiply)¶ Superimposes two images on top of each other. If you multiply an image with a solid black image, the result is black. If you multiply with a solid white image, the image is unaffected. out = image1 * image2 / MAX Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.soft_light(_image1 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _image2 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#soft_light)¶ Superimposes two images on top of each other using the Soft Light algorithm Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.hard_light(_image1 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _image2 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#hard_light)¶ Superimposes two images on top of each other using the Hard Light algorithm Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.overlay(_image1 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _image2 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#overlay)¶ Superimposes two images on top of each other using the Overlay algorithm Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.offset(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _xoffset : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _yoffset : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#offset)¶ Returns a copy of the image where data has been offset by the given distances. Data wraps around the edges. If `yoffset` is omitted, it is assumed to be equal to `xoffset`. Parameters: * **image** – Input image. * **xoffset** – The horizontal distance. * **yoffset** – The vertical distance. If omitted, both distances are set to the same value. Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.screen(_image1 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _image2 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#screen)¶ Superimposes two inverted images on top of each other. out = MAX - ((MAX - image1) * (MAX - image2) / MAX) Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.subtract(_image1 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _image2 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _scale : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") = 1.0_, _offset : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") = 0_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#subtract)¶ Subtracts two images, dividing the result by scale and adding the offset. If omitted, scale defaults to 1.0, and offset to 0.0. out = ((image1 - image2) / scale + offset) Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") PIL.ImageChops.subtract_modulo(_image1 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _image2 : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageChops.html#subtract_modulo)¶ Subtract two images, without clipping the result. out = ((image1 - image2) % MAX) Return type: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") [ Next `ImageCms` module ](ImageCms.html) [ Previous `Image` module ](Image.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImageChops` (“channel operations”) module * Functions * `add()` * `add_modulo()` * `blend()` * `composite()` * `constant()` * `darker()` * `difference()` * `duplicate()` * `invert()` * `lighter()` * `logical_and()` * `logical_or()` * `logical_xor()` * `multiply()` * `soft_light()` * `hard_light()` * `overlay()` * `offset()` * `screen()` * `subtract()` * `subtract_modulo()` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImageCms.html # Path: reference/ImageCms.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * `ImageCms` module * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImageCms.rst.txt "View this page") # `ImageCms` module¶ The `ImageCms` module provides color profile management support using the LittleCMS2 color management engine, based on Kevin Cazabon’s PyCMS library. class PIL.ImageCms.ImageCmsProfile(_profile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile_)[[source]](../_modules/PIL/ImageCms.html#ImageCmsProfile)¶ __init__(_profile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageCms.html#ImageCmsProfile.__init__)¶ Parameters: **profile** – Either a string representing a filename, a file like object containing a profile or a low-level profile object tobytes() -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageCms.html#ImageCmsProfile.tobytes)¶ Returns the profile in a format suitable for embedding in saved images. Returns: a bytes object containing the ICC profile. class PIL.ImageCms.ImageCmsTransform(_input : ImageCmsProfile_, _output : ImageCmsProfile_, _input_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _output_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _intent : Intent = Intent.PERCEPTUAL_, _proof : ImageCmsProfile | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _proof_intent : Intent = Intent.ABSOLUTE_COLORIMETRIC_, _flags : Flags = _)[[source]](../_modules/PIL/ImageCms.html#ImageCmsTransform)¶ Bases: [`ImagePointHandler`](Image.html#PIL.Image.ImagePointHandler "PIL.Image.ImagePointHandler") Transform. This can be used with the procedural API, or with the standard [`point()`](Image.html#PIL.Image.Image.point "PIL.Image.Image.point") method. Will return the output profile in the `output.info['icc_profile']`. apply(_im : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _imOut : [Image](Image.html#PIL.Image.Image "PIL.Image.Image") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageCms.html#ImageCmsTransform.apply)¶ apply_in_place(_im : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageCms.html#ImageCmsTransform.apply_in_place)¶ point(_im : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageCms.html#ImageCmsTransform.point)¶ exception PIL.ImageCms.PyCMSError[[source]](../_modules/PIL/ImageCms.html#PyCMSError)¶ (pyCMS) Exception class. This is used for all errors in the pyCMS API. ## Constants¶ class PIL.ImageCms.Intent(_* values_)[[source]](../_modules/PIL/ImageCms.html#Intent)¶ Bases: [`IntEnum`](https://docs.python.org/3/library/enum.html#enum.IntEnum "\(in Python v3.14\)") PERCEPTUAL = 0¶ RELATIVE_COLORIMETRIC = 1¶ SATURATION = 2¶ ABSOLUTE_COLORIMETRIC = 3¶ class PIL.ImageCms.Direction(_* values_)[[source]](../_modules/PIL/ImageCms.html#Direction)¶ Bases: [`IntEnum`](https://docs.python.org/3/library/enum.html#enum.IntEnum "\(in Python v3.14\)") INPUT = 0¶ OUTPUT = 1¶ PROOF = 2¶ class PIL.ImageCms.Flags(_* values_)[[source]](../_modules/PIL/ImageCms.html#Flags)¶ Bases: [`IntFlag`](https://docs.python.org/3/library/enum.html#enum.IntFlag "\(in Python v3.14\)") Flags and documentation are taken from `lcms2.h`. NONE = 0¶ NOCACHE = 64¶ Inhibit 1-pixel cache NOOPTIMIZE = 256¶ Inhibit optimizations NULLTRANSFORM = 512¶ Don’t transform anyway GAMUTCHECK = 4096¶ Out of Gamut alarm SOFTPROOFING = 16384¶ Do softproofing BLACKPOINTCOMPENSATION = 8192¶ NOWHITEONWHITEFIXUP = 4¶ Don’t fix scum dot HIGHRESPRECALC = 1024¶ Use more memory to give better accuracy LOWRESPRECALC = 2048¶ Use less memory to minimize resources USE_8BITS_DEVICELINK = 8¶ Create 8 bits devicelinks GUESSDEVICECLASS = 32¶ Guess device class (for `transform2devicelink`) KEEP_SEQUENCE = 128¶ Keep profile sequence for devicelink creation FORCE_CLUT = 2¶ Force CLUT optimization CLUT_POST_LINEARIZATION = 1¶ create postlinearization tables if possible CLUT_PRE_LINEARIZATION = 16¶ create prelinearization tables if possible NONEGATIVES = 32768¶ Prevent negative numbers in floating point transforms COPY_ALPHA = 67108864¶ Alpha channels are copied on `cmsDoTransform()` NODEFAULTRESOURCEDEF = 16777216¶ static GRIDPOINTS(_n : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> Flags[[source]](../_modules/PIL/ImageCms.html#Flags.GRIDPOINTS)¶ Fine-tune control over number of gridpoints Parameters: **n** – [`int`](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") in range `0 <= n <= 255` ## Functions¶ PIL.ImageCms.applyTransform(_im : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _transform : ImageCmsTransform_, _inPlace : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = False_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageCms.html#applyTransform)¶ (pyCMS) Applies a transform to a given image. If `im.mode != transform.input_mode`, a `PyCMSError` is raised. If `inPlace` is `True` and `transform.input_mode != transform.output_mode`, a `PyCMSError` is raised. If `im.mode`, `transform.input_mode` or `transform.output_mode` is not supported by pyCMSdll or the profiles you used for the transform, a `PyCMSError` is raised. If an error occurs while the transform is being applied, a `PyCMSError` is raised. This function applies a pre-calculated transform (from ImageCms.buildTransform() or ImageCms.buildTransformFromOpenProfiles()) to an image. The transform can be used for multiple images, saving considerable calculation time if doing the same conversion multiple times. If you want to modify im in-place instead of receiving a new image as the return value, set `inPlace` to `True`. This can only be done if `transform.input_mode` and `transform.output_mode` are the same, because we can’t change the mode in-place (the buffer sizes for some modes are different). The default behavior is to return a new [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") object of the same dimensions in mode `transform.output_mode`. Parameters: * **im** – An [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") object, and `im.mode` must be the same as the `input_mode` supported by the transform. * **transform** – A valid CmsTransform class object * **inPlace** – Bool. If `True`, `im` is modified in place and `None` is returned, if `False`, a new [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") object with the transform applied is returned (and `im` is not changed). The default is `False`. Returns: Either `None`, or a new [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") object, depending on the value of `inPlace`. The profile will be returned in the image’s `info['icc_profile']`. Raises: **PyCMSError** – PIL.ImageCms.buildProofTransform(_inputProfile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_, _outputProfile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_, _proofProfile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_, _inMode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _outMode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _renderingIntent : Intent = Intent.PERCEPTUAL_, _proofRenderingIntent : Intent = Intent.ABSOLUTE_COLORIMETRIC_, _flags : Flags = _) -> ImageCmsTransform[[source]](../_modules/PIL/ImageCms.html#buildProofTransform)¶ (pyCMS) Builds an ICC transform mapping from the `inputProfile` to the `outputProfile`, but tries to simulate the result that would be obtained on the `proofProfile` device. If the input, output, or proof profiles specified are not valid filenames, a `PyCMSError` will be raised. If an error occurs during creation of the transform, a `PyCMSError` will be raised. If `inMode` or `outMode` are not a mode supported by the `outputProfile` (or by pyCMS), a `PyCMSError` will be raised. This function builds and returns an ICC transform from the `inputProfile` to the `outputProfile`, but tries to simulate the result that would be obtained on the `proofProfile` device using `renderingIntent` and `proofRenderingIntent` to determine what to do with out-of-gamut colors. This is known as “soft-proofing”. It will ONLY work for converting images that are in `inMode` to images that are in outMode color format (PIL mode, i.e. “RGB”, “RGBA”, “CMYK”, etc.). Usage of the resulting transform object is exactly the same as with ImageCms.buildTransform(). Proof profiling is generally used when using an output device to get a good idea of what the final printed/displayed image would look like on the `proofProfile` device when it’s quicker and easier to use the output device for judging color. Generally, this means that the output device is a monitor, or a dye-sub printer (etc.), and the simulated device is something more expensive, complicated, or time consuming (making it difficult to make a real print for color judgement purposes). Soft-proofing basically functions by adjusting the colors on the output device to match the colors of the device being simulated. However, when the simulated device has a much wider gamut than the output device, you may obtain marginal results. Parameters: * **inputProfile** – String, as a valid filename path to the ICC input profile you wish to use for this transform, or a profile object * **outputProfile** – String, as a valid filename path to the ICC output (monitor, usually) profile you wish to use for this transform, or a profile object * **proofProfile** – String, as a valid filename path to the ICC proof profile you wish to use for this transform, or a profile object * **inMode** – String, as a valid PIL mode that the appropriate profile also supports (i.e. “RGB”, “RGBA”, “CMYK”, etc.) * **outMode** – String, as a valid PIL mode that the appropriate profile also supports (i.e. “RGB”, “RGBA”, “CMYK”, etc.) * **renderingIntent** – Integer (0-3) specifying the rendering intent you wish to use for the input->proof (simulated) transform > ImageCms.Intent.PERCEPTUAL = 0 (DEFAULT) > ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 > ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3 see the pyCMS documentation for details on rendering intents and what they do. * **proofRenderingIntent** – Integer (0-3) specifying the rendering intent you wish to use for proof->output transform > ImageCms.Intent.PERCEPTUAL = 0 (DEFAULT) > ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 > ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3 see the pyCMS documentation for details on rendering intents and what they do. * **flags** – Integer (0-…) specifying additional flags Returns: A CmsTransform class object. Raises: **PyCMSError** – PIL.ImageCms.buildProofTransformFromOpenProfiles(_inputProfile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_, _outputProfile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_, _proofProfile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_, _inMode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _outMode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _renderingIntent : Intent = Intent.PERCEPTUAL_, _proofRenderingIntent : Intent = Intent.ABSOLUTE_COLORIMETRIC_, _flags : Flags = _) -> ImageCmsTransform¶ (pyCMS) Builds an ICC transform mapping from the `inputProfile` to the `outputProfile`, but tries to simulate the result that would be obtained on the `proofProfile` device. If the input, output, or proof profiles specified are not valid filenames, a `PyCMSError` will be raised. If an error occurs during creation of the transform, a `PyCMSError` will be raised. If `inMode` or `outMode` are not a mode supported by the `outputProfile` (or by pyCMS), a `PyCMSError` will be raised. This function builds and returns an ICC transform from the `inputProfile` to the `outputProfile`, but tries to simulate the result that would be obtained on the `proofProfile` device using `renderingIntent` and `proofRenderingIntent` to determine what to do with out-of-gamut colors. This is known as “soft-proofing”. It will ONLY work for converting images that are in `inMode` to images that are in outMode color format (PIL mode, i.e. “RGB”, “RGBA”, “CMYK”, etc.). Usage of the resulting transform object is exactly the same as with ImageCms.buildTransform(). Proof profiling is generally used when using an output device to get a good idea of what the final printed/displayed image would look like on the `proofProfile` device when it’s quicker and easier to use the output device for judging color. Generally, this means that the output device is a monitor, or a dye-sub printer (etc.), and the simulated device is something more expensive, complicated, or time consuming (making it difficult to make a real print for color judgement purposes). Soft-proofing basically functions by adjusting the colors on the output device to match the colors of the device being simulated. However, when the simulated device has a much wider gamut than the output device, you may obtain marginal results. Parameters: * **inputProfile** – String, as a valid filename path to the ICC input profile you wish to use for this transform, or a profile object * **outputProfile** – String, as a valid filename path to the ICC output (monitor, usually) profile you wish to use for this transform, or a profile object * **proofProfile** – String, as a valid filename path to the ICC proof profile you wish to use for this transform, or a profile object * **inMode** – String, as a valid PIL mode that the appropriate profile also supports (i.e. “RGB”, “RGBA”, “CMYK”, etc.) * **outMode** – String, as a valid PIL mode that the appropriate profile also supports (i.e. “RGB”, “RGBA”, “CMYK”, etc.) * **renderingIntent** – Integer (0-3) specifying the rendering intent you wish to use for the input->proof (simulated) transform > ImageCms.Intent.PERCEPTUAL = 0 (DEFAULT) > ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 > ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3 see the pyCMS documentation for details on rendering intents and what they do. * **proofRenderingIntent** – Integer (0-3) specifying the rendering intent you wish to use for proof->output transform > ImageCms.Intent.PERCEPTUAL = 0 (DEFAULT) > ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 > ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3 see the pyCMS documentation for details on rendering intents and what they do. * **flags** – Integer (0-…) specifying additional flags Returns: A CmsTransform class object. Raises: **PyCMSError** – PIL.ImageCms.buildTransform(_inputProfile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_, _outputProfile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_, _inMode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _outMode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _renderingIntent : Intent = Intent.PERCEPTUAL_, _flags : Flags = _) -> ImageCmsTransform[[source]](../_modules/PIL/ImageCms.html#buildTransform)¶ (pyCMS) Builds an ICC transform mapping from the `inputProfile` to the `outputProfile`. Use applyTransform to apply the transform to a given image. If the input or output profiles specified are not valid filenames, a `PyCMSError` will be raised. If an error occurs during creation of the transform, a `PyCMSError` will be raised. If `inMode` or `outMode` are not a mode supported by the `outputProfile` (or by pyCMS), a `PyCMSError` will be raised. This function builds and returns an ICC transform from the `inputProfile` to the `outputProfile` using the `renderingIntent` to determine what to do with out-of-gamut colors. It will ONLY work for converting images that are in `inMode` to images that are in `outMode` color format (PIL mode, i.e. “RGB”, “RGBA”, “CMYK”, etc.). Building the transform is a fair part of the overhead in ImageCms.profileToProfile(), so if you’re planning on converting multiple images using the same input/output settings, this can save you time. Once you have a transform object, it can be used with ImageCms.applyProfile() to convert images without the need to re-compute the lookup table for the transform. The reason pyCMS returns a class object rather than a handle directly to the transform is that it needs to keep track of the PIL input/output modes that the transform is meant for. These attributes are stored in the `inMode` and `outMode` attributes of the object (which can be manually overridden if you really want to, but I don’t know of any time that would be of use, or would even work). Parameters: * **inputProfile** – String, as a valid filename path to the ICC input profile you wish to use for this transform, or a profile object * **outputProfile** – String, as a valid filename path to the ICC output profile you wish to use for this transform, or a profile object * **inMode** – String, as a valid PIL mode that the appropriate profile also supports (i.e. “RGB”, “RGBA”, “CMYK”, etc.) * **outMode** – String, as a valid PIL mode that the appropriate profile also supports (i.e. “RGB”, “RGBA”, “CMYK”, etc.) * **renderingIntent** – Integer (0-3) specifying the rendering intent you wish to use for the transform > ImageCms.Intent.PERCEPTUAL = 0 (DEFAULT) > ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 > ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3 see the pyCMS documentation for details on rendering intents and what they do. * **flags** – Integer (0-…) specifying additional flags Returns: A CmsTransform class object. Raises: **PyCMSError** – PIL.ImageCms.buildTransformFromOpenProfiles(_inputProfile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_, _outputProfile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_, _inMode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _outMode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _renderingIntent : Intent = Intent.PERCEPTUAL_, _flags : Flags = _) -> ImageCmsTransform¶ (pyCMS) Builds an ICC transform mapping from the `inputProfile` to the `outputProfile`. Use applyTransform to apply the transform to a given image. If the input or output profiles specified are not valid filenames, a `PyCMSError` will be raised. If an error occurs during creation of the transform, a `PyCMSError` will be raised. If `inMode` or `outMode` are not a mode supported by the `outputProfile` (or by pyCMS), a `PyCMSError` will be raised. This function builds and returns an ICC transform from the `inputProfile` to the `outputProfile` using the `renderingIntent` to determine what to do with out-of-gamut colors. It will ONLY work for converting images that are in `inMode` to images that are in `outMode` color format (PIL mode, i.e. “RGB”, “RGBA”, “CMYK”, etc.). Building the transform is a fair part of the overhead in ImageCms.profileToProfile(), so if you’re planning on converting multiple images using the same input/output settings, this can save you time. Once you have a transform object, it can be used with ImageCms.applyProfile() to convert images without the need to re-compute the lookup table for the transform. The reason pyCMS returns a class object rather than a handle directly to the transform is that it needs to keep track of the PIL input/output modes that the transform is meant for. These attributes are stored in the `inMode` and `outMode` attributes of the object (which can be manually overridden if you really want to, but I don’t know of any time that would be of use, or would even work). Parameters: * **inputProfile** – String, as a valid filename path to the ICC input profile you wish to use for this transform, or a profile object * **outputProfile** – String, as a valid filename path to the ICC output profile you wish to use for this transform, or a profile object * **inMode** – String, as a valid PIL mode that the appropriate profile also supports (i.e. “RGB”, “RGBA”, “CMYK”, etc.) * **outMode** – String, as a valid PIL mode that the appropriate profile also supports (i.e. “RGB”, “RGBA”, “CMYK”, etc.) * **renderingIntent** – Integer (0-3) specifying the rendering intent you wish to use for the transform > ImageCms.Intent.PERCEPTUAL = 0 (DEFAULT) > ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 > ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3 see the pyCMS documentation for details on rendering intents and what they do. * **flags** – Integer (0-…) specifying additional flags Returns: A CmsTransform class object. Raises: **PyCMSError** – PIL.ImageCms.createProfile(_colorSpace : [Literal](https://docs.python.org/3/library/typing.html#typing.Literal "\(in Python v3.14\)")['LAB', 'XYZ', 'sRGB']_, _colorTemp : [SupportsFloat](https://docs.python.org/3/library/typing.html#typing.SupportsFloat "\(in Python v3.14\)") = 0_) -> CmsProfile[[source]](../_modules/PIL/ImageCms.html#createProfile)¶ (pyCMS) Creates a profile. If colorSpace not in `["LAB", "XYZ", "sRGB"]`, a `PyCMSError` is raised. If using LAB and `colorTemp` is not a positive integer, a `PyCMSError` is raised. If an error occurs while creating the profile, a `PyCMSError` is raised. Use this function to create common profiles on-the-fly instead of having to supply a profile on disk and knowing the path to it. It returns a normal CmsProfile object that can be passed to ImageCms.buildTransformFromOpenProfiles() to create a transform to apply to images. Parameters: * **colorSpace** – String, the color space of the profile you wish to create. Currently only “LAB”, “XYZ”, and “sRGB” are supported. * **colorTemp** – Positive number for the white point for the profile, in degrees Kelvin (i.e. 5000, 6500, 9600, etc.). The default is for D50 illuminant if omitted (5000k). colorTemp is ONLY applied to LAB profiles, and is ignored for XYZ and sRGB. Returns: A CmsProfile class object Raises: **PyCMSError** – PIL.ImageCms.getDefaultIntent(_profile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_) -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageCms.html#getDefaultIntent)¶ (pyCMS) Gets the default intent name for the given profile. If `profile` isn’t a valid CmsProfile object or filename to a profile, a `PyCMSError` is raised. If an error occurs while trying to obtain the default intent, a `PyCMSError` is raised. Use this function to determine the default (and usually best optimized) rendering intent for this profile. Most profiles support multiple rendering intents, but are intended mostly for one type of conversion. If you wish to use a different intent than returned, use ImageCms.isIntentSupported() to verify it will work first. Parameters: **profile** – EITHER a valid CmsProfile object, OR a string of the filename of an ICC profile. Returns: Integer 0-3 specifying the default rendering intent for this profile. > ImageCms.Intent.PERCEPTUAL = 0 (DEFAULT) > ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 > ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3 see the pyCMS documentation for details on rendering intents and what they do. Raises: **PyCMSError** – PIL.ImageCms.getOpenProfile(_profileFilename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile_) -> ImageCmsProfile[[source]](../_modules/PIL/ImageCms.html#getOpenProfile)¶ (pyCMS) Opens an ICC profile file. The PyCMSProfile object can be passed back into pyCMS for use in creating transforms and such (as in ImageCms.buildTransformFromOpenProfiles()). If `profileFilename` is not a valid filename for an ICC profile, a `PyCMSError` will be raised. Parameters: **profileFilename** – String, as a valid filename path to the ICC profile you wish to open, or a file-like object. Returns: A CmsProfile class object. Raises: **PyCMSError** – PIL.ImageCms.getProfileCopyright(_profile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_) -> [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageCms.html#getProfileCopyright)¶ (pyCMS) Gets the copyright for the given profile. If `profile` isn’t a valid CmsProfile object or filename to a profile, a `PyCMSError` is raised. If an error occurs while trying to obtain the copyright tag, a `PyCMSError` is raised. Use this function to obtain the information stored in the profile’s copyright tag. Parameters: **profile** – EITHER a valid CmsProfile object, OR a string of the filename of an ICC profile. Returns: A string containing the internal profile information stored in an ICC tag. Raises: **PyCMSError** – PIL.ImageCms.getProfileDescription(_profile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_) -> [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageCms.html#getProfileDescription)¶ (pyCMS) Gets the description for the given profile. If `profile` isn’t a valid CmsProfile object or filename to a profile, a `PyCMSError` is raised. If an error occurs while trying to obtain the description tag, a `PyCMSError` is raised. Use this function to obtain the information stored in the profile’s description tag. Parameters: **profile** – EITHER a valid CmsProfile object, OR a string of the filename of an ICC profile. Returns: A string containing the internal profile information stored in an ICC tag. Raises: **PyCMSError** – PIL.ImageCms.getProfileInfo(_profile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_) -> [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageCms.html#getProfileInfo)¶ (pyCMS) Gets the internal product information for the given profile. If `profile` isn’t a valid CmsProfile object or filename to a profile, a `PyCMSError` is raised. If an error occurs while trying to obtain the info tag, a `PyCMSError` is raised. Use this function to obtain the information stored in the profile’s info tag. This often contains details about the profile, and how it was created, as supplied by the creator. Parameters: **profile** – EITHER a valid CmsProfile object, OR a string of the filename of an ICC profile. Returns: A string containing the internal profile information stored in an ICC tag. Raises: **PyCMSError** – PIL.ImageCms.getProfileManufacturer(_profile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_) -> [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageCms.html#getProfileManufacturer)¶ (pyCMS) Gets the manufacturer for the given profile. If `profile` isn’t a valid CmsProfile object or filename to a profile, a `PyCMSError` is raised. If an error occurs while trying to obtain the manufacturer tag, a `PyCMSError` is raised. Use this function to obtain the information stored in the profile’s manufacturer tag. Parameters: **profile** – EITHER a valid CmsProfile object, OR a string of the filename of an ICC profile. Returns: A string containing the internal profile information stored in an ICC tag. Raises: **PyCMSError** – PIL.ImageCms.getProfileModel(_profile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_) -> [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageCms.html#getProfileModel)¶ (pyCMS) Gets the model for the given profile. If `profile` isn’t a valid CmsProfile object or filename to a profile, a `PyCMSError` is raised. If an error occurs while trying to obtain the model tag, a `PyCMSError` is raised. Use this function to obtain the information stored in the profile’s model tag. Parameters: **profile** – EITHER a valid CmsProfile object, OR a string of the filename of an ICC profile. Returns: A string containing the internal profile information stored in an ICC tag. Raises: **PyCMSError** – PIL.ImageCms.getProfileName(_profile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_) -> [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageCms.html#getProfileName)¶ (pyCMS) Gets the internal product name for the given profile. If `profile` isn’t a valid CmsProfile object or filename to a profile, a `PyCMSError` is raised If an error occurs while trying to obtain the name tag, a `PyCMSError` is raised. Use this function to obtain the INTERNAL name of the profile (stored in an ICC tag in the profile itself), usually the one used when the profile was originally created. Sometimes this tag also contains additional information supplied by the creator. Parameters: **profile** – EITHER a valid CmsProfile object, OR a string of the filename of an ICC profile. Returns: A string containing the internal name of the profile as stored in an ICC tag. Raises: **PyCMSError** – PIL.ImageCms.get_display_profile(_handle : [SupportsInt](https://docs.python.org/3/library/typing.html#typing.SupportsInt "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> ImageCmsProfile | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageCms.html#get_display_profile)¶ (experimental) Fetches the profile for the current display device. Returns: `None` if the profile is not known. PIL.ImageCms.isIntentSupported(_profile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_, _intent : Intent_, _direction : Direction_) -> [Literal](https://docs.python.org/3/library/typing.html#typing.Literal "\(in Python v3.14\)")[-1, 1][[source]](../_modules/PIL/ImageCms.html#isIntentSupported)¶ (pyCMS) Checks if a given intent is supported. Use this function to verify that you can use your desired `intent` with `profile`, and that `profile` can be used for the input/output/proof profile as you desire. Some profiles are created specifically for one “direction”, can cannot be used for others. Some profiles can only be used for certain rendering intents, so it’s best to either verify this before trying to create a transform with them (using this function), or catch the potential `PyCMSError` that will occur if they don’t support the modes you select. Parameters: * **profile** – EITHER a valid CmsProfile object, OR a string of the filename of an ICC profile. * **intent** – Integer (0-3) specifying the rendering intent you wish to use with this profile > ImageCms.Intent.PERCEPTUAL = 0 (DEFAULT) > ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 > ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3 see the pyCMS documentation for details on rendering intents and what they do. * **direction** – Integer specifying if the profile is to be used for input, output, or proof > INPUT = 0 (or use ImageCms.Direction.INPUT) OUTPUT = 1 (or use > ImageCms.Direction.OUTPUT) PROOF = 2 (or use ImageCms.Direction.PROOF) Returns: 1 if the intent/direction are supported, -1 if they are not. Raises: **PyCMSError** – PIL.ImageCms.profileToProfile(_im : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _inputProfile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_, _outputProfile : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | CmsProfile | ImageCmsProfile_, _renderingIntent : Intent = Intent.PERCEPTUAL_, _outputMode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _inPlace : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = False_, _flags : Flags = _) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageCms.html#profileToProfile)¶ (pyCMS) Applies an ICC transformation to a given image, mapping from `inputProfile` to `outputProfile`. If the input or output profiles specified are not valid filenames, a `PyCMSError` will be raised. If `inPlace` is `True` and `outputMode != im.mode`, a `PyCMSError` will be raised. If an error occurs during application of the profiles, a `PyCMSError` will be raised. If `outputMode` is not a mode supported by the `outputProfile` (or by pyCMS), a `PyCMSError` will be raised. This function applies an ICC transformation to im from `inputProfile`’s color space to `outputProfile`’s color space using the specified rendering intent to decide how to handle out-of-gamut colors. `outputMode` can be used to specify that a color mode conversion is to be done using these profiles, but the specified profiles must be able to handle that mode. I.e., if converting im from RGB to CMYK using profiles, the input profile must handle RGB data, and the output profile must handle CMYK data. Parameters: * **im** – An open [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") object (i.e. Image.new(…) or Image.open(…), etc.) * **inputProfile** – String, as a valid filename path to the ICC input profile you wish to use for this image, or a profile object * **outputProfile** – String, as a valid filename path to the ICC output profile you wish to use for this image, or a profile object * **renderingIntent** – Integer (0-3) specifying the rendering intent you wish to use for the transform > ImageCms.Intent.PERCEPTUAL = 0 (DEFAULT) > ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 > ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3 see the pyCMS documentation for details on rendering intents and what they do. * **outputMode** – A valid PIL mode for the output image (i.e. “RGB”, “CMYK”, etc.). Note: if rendering the image “inPlace”, outputMode MUST be the same mode as the input, or omitted completely. If omitted, the outputMode will be the same as the mode of the input image (im.mode) * **inPlace** – Boolean. If `True`, the original image is modified in-place, and `None` is returned. If `False` (default), a new [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") object is returned with the transform applied. * **flags** – Integer (0-…) specifying additional flags Returns: Either None or a new [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") object, depending on the value of `inPlace` Raises: **PyCMSError** – ## CmsProfile¶ The ICC color profiles are wrapped in an instance of the class `CmsProfile`. The specification ICC.1:2010 contains more information about the meaning of the values in ICC profiles. For convenience, all XYZ-values are also given as xyY-values (so they can be easily displayed in a chromaticity diagram, for example). class PIL.ImageCms.core.CmsProfile¶ creation_date: [datetime.datetime](https://docs.python.org/3/library/datetime.html#datetime.datetime "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ Date and time this profile was first created (see 7.2.1 of ICC.1:2010). version: [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")¶ The version number of the ICC standard that this profile follows (e.g. `2.0`). icc_version: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ Same as `version`, but in encoded format (see 7.2.4 of ICC.1:2010). device_class: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")¶ 4-character string identifying the profile class. One of `scnr`, `mntr`, `prtr`, `link`, `spac`, `abst`, `nmcl` (see 7.2.5 of ICC.1:2010 for details). xcolor_space: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")¶ 4-character string (padded with whitespace) identifying the color space, e.g. `XYZ␣`, `RGB␣` or `CMYK` (see 7.2.6 of ICC.1:2010 for details). connection_space: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")¶ 4-character string (padded with whitespace) identifying the color space on the B-side of the transform (see 7.2.7 of ICC.1:2010 for details). header_flags: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ The encoded header flags of the profile (see 7.2.11 of ICC.1:2010 for details). header_manufacturer: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")¶ 4-character string (padded with whitespace) identifying the device manufacturer, which shall match the signature contained in the appropriate section of the ICC signature registry found at www.color.org (see 7.2.12 of ICC.1:2010). header_model: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")¶ 4-character string (padded with whitespace) identifying the device model, which shall match the signature contained in the appropriate section of the ICC signature registry found at www.color.org (see 7.2.13 of ICC.1:2010). attributes: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ Flags used to identify attributes unique to the particular device setup for which the profile is applicable (see 7.2.14 of ICC.1:2010 for details). rendering_intent: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ The rendering intent to use when combining this profile with another profile (usually overridden at run-time, but provided here for DeviceLink and embedded source profiles, see 7.2.15 of ICC.1:2010). One of `ImageCms.Intent.ABSOLUTE_COLORIMETRIC`, `ImageCms.Intent.PERCEPTUAL`, `ImageCms.Intent.RELATIVE_COLORIMETRIC` and `ImageCms.Intent.SATURATION`. profile_id: [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")¶ A sequence of 16 bytes identifying the profile (via a specially constructed MD5 sum), or 16 binary zeroes if the profile ID has not been calculated (see 7.2.18 of ICC.1:2010). copyright: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ The text copyright information for the profile (see 9.2.21 of ICC.1:2010). manufacturer: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ The (English) display string for the device manufacturer (see 9.2.22 of ICC.1:2010). model: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ The (English) display string for the device model of the device for which this profile is created (see 9.2.23 of ICC.1:2010). profile_description: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ The (English) display string for the profile description (see 9.2.41 of ICC.1:2010). target: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ The name of the registered characterization data set, or the measurement data for a characterization target (see 9.2.14 of ICC.1:2010). red_colorant: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ The first column in the matrix used in matrix/TRC transforms (see 9.2.44 of ICC.1:2010). The value is in the format `((X, Y, Z), (x, y, Y))`, if available. green_colorant: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ The second column in the matrix used in matrix/TRC transforms (see 9.2.30 of ICC.1:2010). The value is in the format `((X, Y, Z), (x, y, Y))`, if available. blue_colorant: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ The third column in the matrix used in matrix/TRC transforms (see 9.2.4 of ICC.1:2010). The value is in the format `((X, Y, Z), (x, y, Y))`, if available. luminance: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ The absolute luminance of emissive devices in candelas per square metre as described by the Y channel (see 9.2.32 of ICC.1:2010). The value is in the format `((X, Y, Z), (x, y, Y))`, if available. chromaticity: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ The data of the phosphor/colorant chromaticity set used (red, green and blue channels, see 9.2.16 of ICC.1:2010). The value is in the format `((x, y, Y), (x, y, Y), (x, y, Y))`, if available. chromatic_adaption: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ The chromatic adaption matrix converts a color measured using the actual illumination conditions and relative to the actual adopted white, to a color relative to the PCS adopted white, with complete adaptation from the actual adopted white chromaticity to the PCS adopted white chromaticity (see 9.2.15 of ICC.1:2010). Two 3-tuples of floats are returned in a 2-tuple, one in (X, Y, Z) space and one in (x, y, Y) space. colorant_table: [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")]¶ This tag identifies the colorants used in the profile by a unique name and set of PCSXYZ or PCSLAB values (see 9.2.19 of ICC.1:2010). colorant_table_out: [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")]¶ This tag identifies the colorants used in the profile by a unique name and set of PCSLAB values (for DeviceLink profiles only, see 9.2.19 of ICC.1:2010). colorimetric_intent: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ 4-character string (padded with whitespace) identifying the image state of PCS colorimetry produced using the colorimetric intent transforms (see 9.2.20 of ICC.1:2010 for details). perceptual_rendering_intent_gamut: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ 4-character string (padded with whitespace) identifying the (one) standard reference medium gamut (see 9.2.37 of ICC.1:2010 for details). saturation_rendering_intent_gamut: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ 4-character string (padded with whitespace) identifying the (one) standard reference medium gamut (see 9.2.37 of ICC.1:2010 for details). technology: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ 4-character string (padded with whitespace) identifying the device technology (see 9.2.47 of ICC.1:2010 for details). media_black_point: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ This tag specifies the media black point and is used for generating absolute colorimetry. This tag was available in ICC 3.2, but it is removed from version 4. The value is in the format `((X, Y, Z), (x, y, Y))`, if available. media_white_point: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ This tag specifies the media white point and is used for generating absolute colorimetry. The value is in the format `((X, Y, Z), (x, y, Y))`, if available. media_white_point_temperature: [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ Calculates the white point temperature (see the LCMS documentation for more information). viewing_condition: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ The (English) display string for the viewing conditions (see 9.2.48 of ICC.1:2010). screening_description: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ The (English) display string for the screening conditions. This tag was available in ICC 3.2, but it is removed from version 4. red_primary: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ The XYZ-transformed of the RGB primary color red (1, 0, 0). The value is in the format `((X, Y, Z), (x, y, Y))`, if available. green_primary: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ The XYZ-transformed of the RGB primary color green (0, 1, 0). The value is in the format `((X, Y, Z), (x, y, Y))`, if available. blue_primary: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ The XYZ-transformed of the RGB primary color blue (0, 0, 1). The value is in the format `((X, Y, Z), (x, y, Y))`, if available. is_matrix_shaper: [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)")¶ True if this profile is implemented as a matrix shaper (see documentation on LCMS). clut: [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)"), [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)"), [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)")]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ Returns a dictionary of all supported intents and directions for the CLUT model. The dictionary is indexed by intents (`ImageCms.Intent.ABSOLUTE_COLORIMETRIC`, `ImageCms.Intent.PERCEPTUAL`, `ImageCms.Intent.RELATIVE_COLORIMETRIC` and `ImageCms.Intent.SATURATION`). The values are 3-tuples indexed by directions (`ImageCms.Direction.INPUT`, `ImageCms.Direction.OUTPUT`, `ImageCms.Direction.PROOF`). The elements of the tuple are booleans. If the value is `True`, that intent is supported for that direction. intent_supported: [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)"), [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)"), [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)")]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ Returns a dictionary of all supported intents and directions. The dictionary is indexed by intents (`ImageCms.Intent.ABSOLUTE_COLORIMETRIC`, `ImageCms.Intent.PERCEPTUAL`, `ImageCms.Intent.RELATIVE_COLORIMETRIC` and `ImageCms.Intent.SATURATION`). The values are 3-tuples indexed by directions (`ImageCms.Direction.INPUT`, `ImageCms.Direction.OUTPUT`, `ImageCms.Direction.PROOF`). The elements of the tuple are booleans. If the value is `True`, that intent is supported for that direction. There is one function defined on the class: is_intent_supported(_intent : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _direction : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _/_)¶ Returns if the intent is supported for the given direction. Note that you can also get this information for all intents and directions with `intent_supported`. Parameters: * **intent** – One of `ImageCms.Intent.ABSOLUTE_COLORIMETRIC`, `ImageCms.Intent.PERCEPTUAL`, `ImageCms.Intent.RELATIVE_COLORIMETRIC` and `ImageCms.Intent.SATURATION`. * **direction** – One of `ImageCms.Direction.INPUT`, `ImageCms.Direction.OUTPUT` and `ImageCms.Direction.PROOF` Returns: Boolean if the intent and direction is supported. [ Next `ImageColor` module ](ImageColor.html) [ Previous `ImageChops` (“channel operations”) module ](ImageChops.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImageCms` module * `ImageCmsProfile` * `ImageCmsProfile.__init__()` * `ImageCmsProfile.tobytes()` * `ImageCmsTransform` * `ImageCmsTransform.apply()` * `ImageCmsTransform.apply_in_place()` * `ImageCmsTransform.point()` * `PyCMSError` * Constants * `Intent` * `Intent.PERCEPTUAL` * `Intent.RELATIVE_COLORIMETRIC` * `Intent.SATURATION` * `Intent.ABSOLUTE_COLORIMETRIC` * `Direction` * `Direction.INPUT` * `Direction.OUTPUT` * `Direction.PROOF` * `Flags` * `Flags.NONE` * `Flags.NOCACHE` * `Flags.NOOPTIMIZE` * `Flags.NULLTRANSFORM` * `Flags.GAMUTCHECK` * `Flags.SOFTPROOFING` * `Flags.BLACKPOINTCOMPENSATION` * `Flags.NOWHITEONWHITEFIXUP` * `Flags.HIGHRESPRECALC` * `Flags.LOWRESPRECALC` * `Flags.USE_8BITS_DEVICELINK` * `Flags.GUESSDEVICECLASS` * `Flags.KEEP_SEQUENCE` * `Flags.FORCE_CLUT` * `Flags.CLUT_POST_LINEARIZATION` * `Flags.CLUT_PRE_LINEARIZATION` * `Flags.NONEGATIVES` * `Flags.COPY_ALPHA` * `Flags.NODEFAULTRESOURCEDEF` * `Flags.GRIDPOINTS()` * Functions * `applyTransform()` * `buildProofTransform()` * `buildProofTransformFromOpenProfiles()` * `buildTransform()` * `buildTransformFromOpenProfiles()` * `createProfile()` * `getDefaultIntent()` * `getOpenProfile()` * `getProfileCopyright()` * `getProfileDescription()` * `getProfileInfo()` * `getProfileManufacturer()` * `getProfileModel()` * `getProfileName()` * `get_display_profile()` * `isIntentSupported()` * `profileToProfile()` * CmsProfile * `CmsProfile` * `CmsProfile.creation_date` * `CmsProfile.version` * `CmsProfile.icc_version` * `CmsProfile.device_class` * `CmsProfile.xcolor_space` * `CmsProfile.connection_space` * `CmsProfile.header_flags` * `CmsProfile.header_manufacturer` * `CmsProfile.header_model` * `CmsProfile.attributes` * `CmsProfile.rendering_intent` * `CmsProfile.profile_id` * `CmsProfile.copyright` * `CmsProfile.manufacturer` * `CmsProfile.model` * `CmsProfile.profile_description` * `CmsProfile.target` * `CmsProfile.red_colorant` * `CmsProfile.green_colorant` * `CmsProfile.blue_colorant` * `CmsProfile.luminance` * `CmsProfile.chromaticity` * `CmsProfile.chromatic_adaption` * `CmsProfile.colorant_table` * `CmsProfile.colorant_table_out` * `CmsProfile.colorimetric_intent` * `CmsProfile.perceptual_rendering_intent_gamut` * `CmsProfile.saturation_rendering_intent_gamut` * `CmsProfile.technology` * `CmsProfile.media_black_point` * `CmsProfile.media_white_point` * `CmsProfile.media_white_point_temperature` * `CmsProfile.viewing_condition` * `CmsProfile.screening_description` * `CmsProfile.red_primary` * `CmsProfile.green_primary` * `CmsProfile.blue_primary` * `CmsProfile.is_matrix_shaper` * `CmsProfile.clut` * `CmsProfile.intent_supported` * `CmsProfile.is_intent_supported()` *[/]: Positional-only parameter separator (PEP 570) --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImageColor.html # Path: reference/ImageColor.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * `ImageColor` module * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImageColor.rst.txt "View this page") # `ImageColor` module¶ The `ImageColor` module contains color tables and converters from CSS3-style color specifiers to RGB tuples. This module is used by [`PIL.Image.new()`](Image.html#PIL.Image.new "PIL.Image.new") and the [`ImageDraw`](ImageDraw.html#module-PIL.ImageDraw "PIL.ImageDraw") module, among others. ## Color names¶ The ImageColor module supports the following string formats: * Hexadecimal color specifiers, given as `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa`, where `r` is red, `g` is green, `b` is blue and `a` is alpha (also called ‘opacity’). For example, `#ff0000` specifies pure red, and `#ff0000cc` specifies red with 80% opacity (`cc` is 204 in decimal form, and 204 / 255 = 0.8). * RGB functions, given as `rgb(red, green, blue)` where the color values are integers in the range 0 to 255. Alternatively, the color values can be given as three percentages (0% to 100%). For example, `rgb(255,0,0)` and `rgb(100%,0%,0%)` both specify pure red. * Hue-Saturation-Lightness (HSL) functions, given as `hsl(hue, saturation%, lightness%)` where hue is the color given as an angle between 0 and 360 (red=0, green=120, blue=240), saturation is a value between 0% and 100% (gray=0%, full color=100%), and lightness is a value between 0% and 100% (black=0%, normal=50%, white=100%). For example, `hsl(0,100%,50%)` is pure red. * Hue-Saturation-Value (HSV) functions, given as `hsv(hue, saturation%, value%)` where hue and saturation are the same as HSL, and value is between 0% and 100% (black=0%, normal=100%). For example, `hsv(0,100%,100%)` is pure red. This format is also known as Hue-Saturation-Brightness (HSB), and can be given as `hsb(hue, saturation%, brightness%)`, where each of the values are used as they are in HSV. * Common HTML color names. The `ImageColor` module provides some 140 standard color names, based on the colors supported by the X Window system and most web browsers. color names are case insensitive. For example, `red` and `Red` both specify pure red. ## Functions¶ PIL.ImageColor.getrgb(_color_)[[source]](../_modules/PIL/ImageColor.html#getrgb)¶ Convert a color string to an RGB tuple. If the string cannot be parsed, this function raises a [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "\(in Python v3.14\)") exception. Added in version 1.1.4. PIL.ImageColor.getcolor(_color_ , _mode_)[[source]](../_modules/PIL/ImageColor.html#getcolor)¶ Same as `getrgb()`, but converts the RGB value to a grayscale value if the mode is not color or a palette image. If the string cannot be parsed, this function raises a [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "\(in Python v3.14\)") exception. Added in version 1.1.4. [ Next `ImageDraw` module ](ImageDraw.html) [ Previous `ImageCms` module ](ImageCms.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImageColor` module * Color names * Functions * `getrgb()` * `getcolor()` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImageDraw.html # Path: reference/ImageDraw.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * `ImageDraw` module * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImageDraw.rst.txt "View this page") # `ImageDraw` module¶ The `ImageDraw` module provides simple 2D graphics for [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") objects. You can use this module to create new images, annotate or retouch existing images, and to generate graphics on the fly for web use. For a more advanced drawing library for PIL, see the [aggdraw module](https://github.com/pytroll/aggdraw). ## Example: Draw a gray cross over an image¶ import sys from PIL import Image, ImageDraw with Image.open("hopper.jpg") as im: draw = ImageDraw.Draw(im) draw.line((0, 0) + im.size, fill=128) draw.line((0, im.size[1], im.size[0], 0), fill=128) # write to stdout im.save(sys.stdout, "PNG") ## Concepts¶ ### Coordinates¶ The graphics interface uses the same coordinate system as PIL itself, with (0, 0) in the upper left corner. Any pixels drawn outside of the image bounds will be discarded. ### Colors¶ To specify colors, you can use numbers or tuples just as you would use with [`PIL.Image.new()`](Image.html#PIL.Image.new "PIL.Image.new"). See [Colors](../handbook/concepts.html#colors) for more information. For palette images (mode “P”), use integers as color indexes. In 1.1.4 and later, you can also use RGB 3-tuples or color names (see below). The drawing layer will automatically assign color indexes, as long as you don’t draw with more than 256 colors. ### Color names¶ See [Color names](ImageColor.html#color-names) for the color names supported by Pillow. ### Alpha channel¶ By default, when drawing onto an existing image, the image’s pixel values are simply replaced by the new color: im = Image.new("RGBA", (1, 1), (255, 0, 0)) d = ImageDraw.Draw(im) d.rectangle((0, 0, 1, 1), (0, 255, 0, 127)) assert im.getpixel((0, 0)) == (0, 255, 0, 127) # Alpha channel values have no effect when drawing with RGB mode im = Image.new("RGB", (1, 1), (255, 0, 0)) d = ImageDraw.Draw(im) d.rectangle((0, 0, 1, 1), (0, 255, 0, 127)) assert im.getpixel((0, 0)) == (0, 255, 0) If you would like to combine translucent color with an RGB image, then initialize the ImageDraw instance with the RGBA mode: from PIL import Image, ImageDraw im = Image.new("RGB", (1, 1), (255, 0, 0)) d = ImageDraw.Draw(im, "RGBA") d.rectangle((0, 0, 1, 1), (0, 255, 0, 127)) assert im.getpixel((0, 0)) == (128, 127, 0) If you would like to combine translucent color with an RGBA image underneath, you will need to combine multiple images: from PIL import Image, ImageDraw im = Image.new("RGBA", (1, 1), (255, 0, 0, 255)) im2 = Image.new("RGBA", (1, 1)) d = ImageDraw.Draw(im2) d.rectangle((0, 0, 1, 1), (0, 255, 0, 127)) im.paste(im2.convert("RGB"), mask=im2) assert im.getpixel((0, 0)) == (128, 127, 0, 255) ### Fonts¶ PIL can use bitmap fonts or OpenType/TrueType fonts. Bitmap fonts are stored in PIL’s own format, where each font typically consists of two files, one named .pil and the other usually named .pbm. The former contains font metrics, the latter raster data. To load a bitmap font, use the load functions in the [`ImageFont`](ImageFont.html#module-PIL.ImageFont "PIL.ImageFont") module. To load a OpenType/TrueType font, use the truetype function in the [`ImageFont`](ImageFont.html#module-PIL.ImageFont "PIL.ImageFont") module. Note that this function depends on third-party libraries, and may not available in all PIL builds. ## Example: Draw partial opacity text¶ from PIL import Image, ImageDraw, ImageFont # get an image with Image.open("Pillow/Tests/images/hopper.png").convert("RGBA") as base: # make a blank image for the text, initialized to transparent text color txt = Image.new("RGBA", base.size, (255, 255, 255, 0)) # get a font fnt = ImageFont.truetype("Pillow/Tests/fonts/FreeMono.ttf", 40) # get a drawing context d = ImageDraw.Draw(txt) # draw text, half opacity d.text((10, 10), "Hello", font=fnt, fill=(255, 255, 255, 128)) # draw text, full opacity d.text((10, 60), "World", font=fnt, fill=(255, 255, 255, 255)) out = Image.alpha_composite(base, txt) out.show() ## Example: Draw multiline text¶ from PIL import Image, ImageDraw, ImageFont # create an image out = Image.new("RGB", (150, 100), (255, 255, 255)) # get a font fnt = ImageFont.truetype("Pillow/Tests/fonts/FreeMono.ttf", 40) # get a drawing context d = ImageDraw.Draw(out) # draw multiline text d.multiline_text((10, 10), "Hello\nWorld", font=fnt, fill=(0, 0, 0)) out.show() ## Functions¶ PIL.ImageDraw.Draw(_im_ , _mode =None_)[[source]](../_modules/PIL/ImageDraw.html#Draw)¶ Creates an object that can be used to draw in the given image. Note that the image will be modified in place. Parameters: * **im** – The image to draw in. * **mode** – Optional mode to use for color values. For RGB images, this argument can be RGB or RGBA (to blend the drawing into the image). For all other modes, this argument must be the same as the image mode. If omitted, the mode defaults to the mode of the image. ## Attributes¶ ImageDraw.fill: [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = False¶ Selects whether `ImageDraw.ink` should be used as a fill or outline color. ImageDraw.font¶ The current default font. Can be set per instance: from PIL import ImageDraw, ImageFont draw = ImageDraw.Draw(image) draw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf") Or globally for all future ImageDraw instances: from PIL import ImageDraw, ImageFont ImageDraw.ImageDraw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf") ImageDraw.fontmode¶ The current font drawing mode. Set to `"1"` to disable antialiasing or `"L"` to enable it. ImageDraw.ink: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ The internal representation of the current default color. ## Methods¶ ImageDraw.getfont()[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.getfont)¶ Get the current default font, `ImageDraw.font`. If the current default font is `None`, it is initialized with [`ImageFont.load_default()`](ImageFont.html#PIL.ImageFont.load_default "PIL.ImageFont.load_default"). Returns: An image font. ImageDraw.arc(_xy_ , _start_ , _end_ , _fill =None_, _width =0_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.arc)¶ Draws an arc (a portion of a circle outline) between the start and end angles, inside the given bounding box. Parameters: * **xy** – Two points to define the bounding box. Sequence of `[(x0, y0), (x1, y1)]` or `[x0, y0, x1, y1]`, where `x1 >= x0` and `y1 >= y0`. * **start** – Starting angle, in degrees. Angles are measured from 3 o’clock, increasing clockwise. * **end** – Ending angle, in degrees. * **fill** – Color to use for the arc. * **width** – The line width, in pixels. Added in version 5.3.0. ImageDraw.bitmap(_xy_ , _bitmap_ , _fill =None_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.bitmap)¶ Draws a bitmap (mask) at the given position, using the current fill color for the non-zero portions. The bitmap should be a valid transparency mask (mode “1”) or matte (mode “L” or “RGBA”). This is equivalent to doing `image.paste(xy, color, bitmap)`. To paste pixel data into an image, use the [`paste()`](Image.html#PIL.Image.Image.paste "PIL.Image.Image.paste") method on the image itself. ImageDraw.chord(_xy_ , _start_ , _end_ , _fill =None_, _outline =None_, _width =1_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.chord)¶ Same as `arc()`, but connects the end points with a straight line. Parameters: * **xy** – Two points to define the bounding box. Sequence of `[(x0, y0), (x1, y1)]` or `[x0, y0, x1, y1]`, where `x1 >= x0` and `y1 >= y0`. * **outline** – Color to use for the outline. * **fill** – Color to use for the fill. * **width** – The line width, in pixels. Added in version 5.3.0. ImageDraw.circle(_xy_ , _radius_ , _fill =None_, _outline =None_, _width =1_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.circle)¶ Draws a circle with a given radius centering on a point. Added in version 10.4.0. Parameters: * **xy** – The point for the center of the circle, e.g. `(x, y)`. * **radius** – Radius of the circle. * **outline** – Color to use for the outline. * **fill** – Color to use for the fill. * **width** – The line width, in pixels. ImageDraw.ellipse(_xy_ , _fill =None_, _outline =None_, _width =1_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.ellipse)¶ Draws an ellipse inside the given bounding box. Parameters: * **xy** – Two points to define the bounding box. Sequence of either `[(x0, y0), (x1, y1)]` or `[x0, y0, x1, y1]`, where `x1 >= x0` and `y1 >= y0`. * **outline** – Color to use for the outline. * **fill** – Color to use for the fill. * **width** – The line width, in pixels. Added in version 5.3.0. ImageDraw.line(_xy_ , _fill =None_, _width =0_, _joint =None_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.line)¶ Draws a line between the coordinates in the `xy` list. The coordinate pixels are included in the drawn line. Parameters: * **xy** – Sequence of either 2-tuples like `[(x, y), (x, y), ...]` or numeric values like `[x, y, x, y, ...]`. * **fill** – Color to use for the line. * **width** – The line width, in pixels. Added in version 1.1.5. Note This option was broken until version 1.1.6. * **joint** – Joint type between a sequence of lines. It can be `"curve"`, for rounded edges, or [`None`](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)"). Added in version 5.3.0. ImageDraw.pieslice(_xy_ , _start_ , _end_ , _fill =None_, _outline =None_, _width =1_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.pieslice)¶ Same as arc, but also draws straight lines between the end points and the center of the bounding box. Parameters: * **xy** – Two points to define the bounding box. Sequence of `[(x0, y0), (x1, y1)]` or `[x0, y0, x1, y1]`, where `x1 >= x0` and `y1 >= y0`. * **start** – Starting angle, in degrees. Angles are measured from 3 o’clock, increasing clockwise. * **end** – Ending angle, in degrees. * **fill** – Color to use for the fill. * **outline** – Color to use for the outline. * **width** – The line width, in pixels. Added in version 5.3.0. ImageDraw.point(_xy_ , _fill =None_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.point)¶ Draws points (individual pixels) at the given coordinates. Parameters: * **xy** – Sequence of either 2-tuples like `[(x, y), (x, y), ...]` or numeric values like `[x, y, x, y, ...]`. * **fill** – Color to use for the point. ImageDraw.polygon(_xy_ , _fill =None_, _outline =None_, _width =1_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.polygon)¶ Draws a polygon. The polygon outline consists of straight lines between the given coordinates, plus a straight line between the last and the first coordinate. The coordinate pixels are included in the drawn polygon. Parameters: * **xy** – Sequence of either 2-tuples like `[(x, y), (x, y), ...]` or numeric values like `[x, y, x, y, ...]`. * **fill** – Color to use for the fill. * **outline** – Color to use for the outline. * **width** – The line width, in pixels. ImageDraw.regular_polygon(_bounding_circle_ , _n_sides_ , _rotation =0_, _fill =None_, _outline =None_, _width =1_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.regular_polygon)¶ Draws a regular polygon inscribed in `bounding_circle`, with `n_sides`, and rotation of `rotation` degrees. Parameters: * **bounding_circle** – The bounding circle is a tuple defined by a point and radius. (e.g. `bounding_circle=(x, y, r)` or `((x, y), r)`). The polygon is inscribed in this circle. * **n_sides** – Number of sides (e.g. `n_sides=3` for a triangle, `6` for a hexagon). * **rotation** – Apply an arbitrary rotation to the polygon (e.g. `rotation=90`, applies a 90 degree rotation). * **fill** – Color to use for the fill. * **outline** – Color to use for the outline. * **width** – The line width, in pixels. ImageDraw.rectangle(_xy_ , _fill =None_, _outline =None_, _width =1_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.rectangle)¶ Draws a rectangle. Parameters: * **xy** – Two points to define the bounding box. Sequence of either `[(x0, y0), (x1, y1)]` or `[x0, y0, x1, y1]`, where `x1 >= x0` and `y1 >= y0`. The bounding box is inclusive of both endpoints. * **fill** – Color to use for the fill. * **outline** – Color to use for the outline. * **width** – The line width, in pixels. Added in version 5.3.0. ImageDraw.rounded_rectangle(_xy_ , _radius =0_, _fill =None_, _outline =None_, _width =1_, _corners =None_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.rounded_rectangle)¶ Draws a rounded rectangle. Parameters: * **xy** – Two points to define the bounding box. Sequence of either `[(x0, y0), (x1, y1)]` or `[x0, y0, x1, y1]`, where `x1 >= x0` and `y1 >= y0`. The bounding box is inclusive of both endpoints. * **radius** – Radius of the corners. * **fill** – Color to use for the fill. * **outline** – Color to use for the outline. * **width** – The line width, in pixels. * **corners** – A tuple of whether to round each corner, `(top_left, top_right, bottom_right, bottom_left)`. Keyword-only argument. Added in version 8.2.0. ImageDraw.shape(_shape_ , _fill =None_, _outline =None_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.shape)¶ Warning This method is experimental. Draw a shape. ImageDraw.text(_xy_ , _text_ , _fill =None_, _font =None_, _anchor =None_, _spacing =4_, _align ='left'_, _direction =None_, _features =None_, _language =None_, _stroke_width =0_, _stroke_fill =None_, _embedded_color =False_, _font_size =None_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.text)¶ Draws the string at the given position. Parameters: * **xy** – The anchor coordinates of the text. * **text** – String to be drawn. If it contains any newline characters, the text is passed on to `multiline_text()`. * **fill** – Color to use for the text. * **font** – An [`ImageFont`](ImageFont.html#PIL.ImageFont.ImageFont "PIL.ImageFont.ImageFont") instance. * **anchor** – The text anchor alignment. Determines the relative location of the anchor to the text. The default alignment is top left, specifically `la` for horizontal text and `lt` for vertical text. See [Text anchors](../handbook/text- anchors.html#text-anchors) for details. This parameter is ignored for non- TrueType fonts. > Note > > This parameter was present in earlier versions of Pillow, but implemented > only in version 8.0.0. * **spacing** – If the text is passed on to `multiline_text()`, the number of pixels between lines. * **align** – If the text is passed on to `multiline_text()`, `"left"`, `"center"`, `"right"` or `"justify"`. Determines the relative alignment of lines. Use the `anchor` parameter to specify the alignment to `xy`. Added in version 11.2.1: `"justify"` * **direction** – Direction of the text. It can be `"rtl"` (right to left), `"ltr"` (left to right) or `"ttb"` (top to bottom). Requires libraqm. Added in version 4.2.0. * **features** – A list of OpenType font features to be used during text layout. This is usually used to turn on optional font features that are not enabled by default, for example `"dlig"` or `"ss01"`, but can be also used to turn off default font features, for example `"-liga"` to disable ligatures or `"-kern"` to disable kerning. To get all supported features, see [OpenType docs](https://learn.microsoft.com/en-us/typography/opentype/spec/featurelist). Requires libraqm. Added in version 4.2.0. * **language** – Language of the text. Different languages may use different glyph shapes or ligatures. This parameter tells the font which language the text is in, and to apply the correct substitutions as appropriate, if available. It should be a [BCP 47 language code](https://www.w3.org/International/articles/language- tags/). Requires libraqm. Added in version 6.0.0. * **stroke_width** – The width of the text stroke. Added in version 6.2.0. * **stroke_fill** – Color to use for the text stroke. If not given, will default to the `fill` parameter. Added in version 6.2.0. * **embedded_color** – Whether to use font embedded color glyphs (COLR, CBDT, SBIX). Added in version 8.0.0. * **font_size** – If `font` is not provided, then the size to use for the default font. Keyword-only argument. Added in version 10.1.0. ImageDraw.multiline_text(_xy_ , _text_ , _fill =None_, _font =None_, _anchor =None_, _spacing =4_, _align ='left'_, _direction =None_, _features =None_, _language =None_, _stroke_width =0_, _stroke_fill =None_, _embedded_color =False_, _font_size =None_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.multiline_text)¶ Draws the string at the given position. Parameters: * **xy** – The anchor coordinates of the text. * **text** – String to be drawn. * **fill** – Color to use for the text. * **font** – An [`ImageFont`](ImageFont.html#PIL.ImageFont.ImageFont "PIL.ImageFont.ImageFont") instance. * **anchor** – The text anchor alignment. Determines the relative location of the anchor to the text. The default alignment is top left, specifically `la` for horizontal text and `lt` for vertical text. See [Text anchors](../handbook/text- anchors.html#text-anchors) for details. This parameter is ignored for non- TrueType fonts. > Note > > This parameter was present in earlier versions of Pillow, but implemented > only in version 8.0.0. * **spacing** – The number of pixels between lines. * **align** – `"left"`, `"center"`, `"right"` or `"justify"`. Determines the relative alignment of lines. Use the `anchor` parameter to specify the alignment to `xy`. Added in version 11.2.1: `"justify"` * **direction** – Direction of the text. It can be `"rtl"` (right to left), `"ltr"` (left to right) or `"ttb"` (top to bottom). Requires libraqm. Added in version 4.2.0. * **features** – A list of OpenType font features to be used during text layout. This is usually used to turn on optional font features that are not enabled by default, for example `"dlig"` or `"ss01"`, but can be also used to turn off default font features, for example `"-liga"` to disable ligatures or `"-kern"` to disable kerning. To get all supported features, see [OpenType docs](https://learn.microsoft.com/en-us/typography/opentype/spec/featurelist). Requires libraqm. Added in version 4.2.0. * **language** – Language of the text. Different languages may use different glyph shapes or ligatures. This parameter tells the font which language the text is in, and to apply the correct substitutions as appropriate, if available. It should be a [BCP 47 language code](https://www.w3.org/International/articles/language- tags/). Requires libraqm. Added in version 6.0.0. * **stroke_width** – The width of the text stroke. Added in version 6.2.0. * **stroke_fill** – Color to use for the text stroke. If not given, will default to the `fill` parameter. Added in version 6.2.0. * **embedded_color** – Whether to use font embedded color glyphs (COLR, CBDT, SBIX). Added in version 8.0.0. * **font_size** – If `font` is not provided, then the size to use for the default font. Keyword-only argument. Added in version 10.1.0. ImageDraw.textlength(_text_ , _font =None_, _direction =None_, _features =None_, _language =None_, _embedded_color =False_, _font_size =None_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.textlength)¶ Returns length (in pixels with 1/64 precision) of given text when rendered in font with provided direction, features, and language. This is the amount by which following text should be offset. Text bounding box may extend past the length in some fonts, e.g. when using italics or accents. The result is returned as a float; it is a whole number if using basic layout. Note that the sum of two lengths may not equal the length of a concatenated string due to kerning. If you need to adjust for kerning, include the following character and subtract its length. For example, instead of hello = draw.textlength("Hello", font) world = draw.textlength("World", font) hello_world = hello + world # not adjusted for kerning assert hello_world == draw.textlength("HelloWorld", font) # may fail use hello = draw.textlength("HelloW", font) - draw.textlength( "W", font ) # adjusted for kerning world = draw.textlength("World", font) hello_world = hello + world # adjusted for kerning assert hello_world == draw.textlength("HelloWorld", font) # True or disable kerning with (requires libraqm) hello = draw.textlength("Hello", font, features=["-kern"]) world = draw.textlength("World", font, features=["-kern"]) hello_world = hello + world # kerning is disabled, no need to adjust assert hello_world == draw.textlength("HelloWorld", font, features=["-kern"]) # True See also [`PIL.ImageText.Text.get_length()`](ImageText.html#PIL.ImageText.Text.get_length "PIL.ImageText.Text.get_length") Added in version 8.0.0. Parameters: * **text** – Text to be measured. May not contain any newline characters. * **font** – An [`ImageFont`](ImageFont.html#PIL.ImageFont.ImageFont "PIL.ImageFont.ImageFont") instance. * **direction** – Direction of the text. It can be `"rtl"` (right to left), `"ltr"` (left to right) or `"ttb"` (top to bottom). Requires libraqm. * **features** – A list of OpenType font features to be used during text layout. This is usually used to turn on optional font features that are not enabled by default, for example `"dlig"` or `"ss01"`, but can be also used to turn off default font features, for example `"-liga"` to disable ligatures or `"-kern"` to disable kerning. To get all supported features, see [OpenType docs](https://learn.microsoft.com/en-us/typography/opentype/spec/featurelist). Requires libraqm. * **language** – Language of the text. Different languages may use different glyph shapes or ligatures. This parameter tells the font which language the text is in, and to apply the correct substitutions as appropriate, if available. It should be a [BCP 47 language code](https://www.w3.org/International/articles/language-tags/). Requires libraqm. * **embedded_color** – Whether to use font embedded color glyphs (COLR, CBDT, SBIX). * **font_size** – If `font` is not provided, then the size to use for the default font. Keyword-only argument. Added in version 10.1.0. Returns: Either width for horizontal text, or height for vertical text. ImageDraw.textbbox(_xy_ , _text_ , _font =None_, _anchor =None_, _spacing =4_, _align ='left'_, _direction =None_, _features =None_, _language =None_, _stroke_width =0_, _embedded_color =False_, _font_size =None_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.textbbox)¶ Returns bounding box (in pixels) of given text relative to given anchor when rendered in font with provided direction, features, and language. Only supported for TrueType fonts. Use `textlength()` to get the offset of following text with 1/64 pixel precision. The bounding box includes extra margins for some fonts, e.g. italics or accents. Added in version 8.0.0. Parameters: * **xy** – The anchor coordinates of the text. * **text** – Text to be measured. If it contains any newline characters, the text is passed on to `multiline_textbbox()`. * **font** – A [`FreeTypeFont`](ImageFont.html#PIL.ImageFont.FreeTypeFont "PIL.ImageFont.FreeTypeFont") instance. * **anchor** – The text anchor alignment. Determines the relative location of the anchor to the text. The default alignment is top left, specifically `la` for horizontal text and `lt` for vertical text. See [Text anchors](../handbook/text-anchors.html#text-anchors) for details. This parameter is ignored for non-TrueType fonts. * **spacing** – If the text is passed on to `multiline_textbbox()`, the number of pixels between lines. * **align** – If the text is passed on to `multiline_textbbox()`, `"left"`, `"center"`, `"right"` or `"justify"`. Determines the relative alignment of lines. Use the `anchor` parameter to specify the alignment to `xy`. Added in version 11.2.1: `"justify"` * **direction** – Direction of the text. It can be `"rtl"` (right to left), `"ltr"` (left to right) or `"ttb"` (top to bottom). Requires libraqm. * **features** – A list of OpenType font features to be used during text layout. This is usually used to turn on optional font features that are not enabled by default, for example `"dlig"` or `"ss01"`, but can be also used to turn off default font features, for example `"-liga"` to disable ligatures or `"-kern"` to disable kerning. To get all supported features, see [OpenType docs](https://learn.microsoft.com/en-us/typography/opentype/spec/featurelist). Requires libraqm. * **language** – Language of the text. Different languages may use different glyph shapes or ligatures. This parameter tells the font which language the text is in, and to apply the correct substitutions as appropriate, if available. It should be a [BCP 47 language code](https://www.w3.org/International/articles/language-tags/). Requires libraqm. * **stroke_width** – The width of the text stroke. * **embedded_color** – Whether to use font embedded color glyphs (COLR, CBDT, SBIX). * **font_size** – If `font` is not provided, then the size to use for the default font. Keyword-only argument. Added in version 10.1.0. Returns: `(left, top, right, bottom)` bounding box ImageDraw.multiline_textbbox(_xy_ , _text_ , _font =None_, _anchor =None_, _spacing =4_, _align ='left'_, _direction =None_, _features =None_, _language =None_, _stroke_width =0_, _embedded_color =False_, _font_size =None_)[[source]](../_modules/PIL/ImageDraw.html#ImageDraw.multiline_textbbox)¶ Returns bounding box (in pixels) of given text relative to given anchor when rendered in font with provided direction, features, and language. Only supported for TrueType fonts. Use `textlength()` to get the offset of following text with 1/64 pixel precision. The bounding box includes extra margins for some fonts, e.g. italics or accents. See also [`PIL.ImageText.Text.get_bbox()`](ImageText.html#PIL.ImageText.Text.get_bbox "PIL.ImageText.Text.get_bbox") Added in version 8.0.0. Parameters: * **xy** – The anchor coordinates of the text. * **text** – Text to be measured. * **font** – A [`FreeTypeFont`](ImageFont.html#PIL.ImageFont.FreeTypeFont "PIL.ImageFont.FreeTypeFont") instance. * **anchor** – The text anchor alignment. Determines the relative location of the anchor to the text. The default alignment is top left, specifically `la` for horizontal text and `lt` for vertical text. See [Text anchors](../handbook/text-anchors.html#text-anchors) for details. This parameter is ignored for non-TrueType fonts. * **spacing** – The number of pixels between lines. * **align** – `"left"`, `"center"`, `"right"` or `"justify"`. Determines the relative alignment of lines. Use the `anchor` parameter to specify the alignment to `xy`. Added in version 11.2.1: `"justify"` * **direction** – Direction of the text. It can be `"rtl"` (right to left), `"ltr"` (left to right) or `"ttb"` (top to bottom). Requires libraqm. * **features** – A list of OpenType font features to be used during text layout. This is usually used to turn on optional font features that are not enabled by default, for example `"dlig"` or `"ss01"`, but can be also used to turn off default font features, for example `"-liga"` to disable ligatures or `"-kern"` to disable kerning. To get all supported features, see [OpenType docs](https://learn.microsoft.com/en-us/typography/opentype/spec/featurelist). Requires libraqm. * **language** – Language of the text. Different languages may use different glyph shapes or ligatures. This parameter tells the font which language the text is in, and to apply the correct substitutions as appropriate, if available. It should be a [BCP 47 language code](https://www.w3.org/International/articles/language-tags/). Requires libraqm. * **stroke_width** – The width of the text stroke. * **embedded_color** – Whether to use font embedded color glyphs (COLR, CBDT, SBIX). * **font_size** – If `font` is not provided, then the size to use for the default font. Keyword-only argument. Added in version 10.1.0. Returns: `(left, top, right, bottom)` bounding box PIL.ImageDraw.getdraw(_im =None_, _hints =None_)[[source]](../_modules/PIL/ImageDraw.html#getdraw)¶ Warning This method is experimental. A more advanced 2D drawing interface for PIL images, based on the WCK interface. Parameters: * **im** – The image to draw in. * **hints** – An optional list of hints. Returns: A (drawing context, drawing resource factory) tuple. PIL.ImageDraw.floodfill(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _xy : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _value : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), ...]_, _border : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), ...] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _thresh : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") = 0_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageDraw.html#floodfill)¶ Warning This method is experimental. Fills a bounded region with a given color. Parameters: * **image** – Target image. * **xy** – Seed position (a 2-item coordinate tuple). See [Coordinate system](../handbook/concepts.html#coordinate-system). * **value** – Fill color. * **border** – Optional border value. If given, the region consists of pixels with a color different from the border color. If not given, the region consists of pixels having the same color as the seed pixel. * **thresh** – Optional threshold value which specifies a maximum tolerable difference of a pixel value from the ‘background’ in order for it to be replaced. Useful for filling regions of non-homogeneous, but similar, colors. [ Next `ImageEnhance` module ](ImageEnhance.html) [ Previous `ImageColor` module ](ImageColor.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImageDraw` module * Example: Draw a gray cross over an image * Concepts * Coordinates * Colors * Color names * Alpha channel * Fonts * Example: Draw partial opacity text * Example: Draw multiline text * Functions * `Draw()` * Attributes * `ImageDraw.fill` * `ImageDraw.font` * `ImageDraw.fontmode` * `ImageDraw.ink` * Methods * `ImageDraw.getfont()` * `ImageDraw.arc()` * `ImageDraw.bitmap()` * `ImageDraw.chord()` * `ImageDraw.circle()` * `ImageDraw.ellipse()` * `ImageDraw.line()` * `ImageDraw.pieslice()` * `ImageDraw.point()` * `ImageDraw.polygon()` * `ImageDraw.regular_polygon()` * `ImageDraw.rectangle()` * `ImageDraw.rounded_rectangle()` * `ImageDraw.shape()` * `ImageDraw.text()` * `ImageDraw.multiline_text()` * `ImageDraw.textlength()` * `ImageDraw.textbbox()` * `ImageDraw.multiline_textbbox()` * `getdraw()` * `floodfill()` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImageEnhance.html # Path: reference/ImageEnhance.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * `ImageEnhance` module * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImageEnhance.rst.txt "View this page") # `ImageEnhance` module¶ The `ImageEnhance` module contains a number of classes that can be used for image enhancement. ## Example: Vary the sharpness of an image¶ from PIL import ImageEnhance enhancer = ImageEnhance.Sharpness(image) for i in range(8): factor = i / 4.0 enhancer.enhance(factor).show(f"Sharpness {factor:f}") Also see the `enhancer.py` demo program in the `Scripts/` directory. ## Classes¶ All enhancement classes implement a common interface, containing a single method: class PIL.ImageEnhance._Enhance[[source]](../_modules/PIL/ImageEnhance.html#_Enhance)¶ enhance(_factor_)[[source]](../_modules/PIL/ImageEnhance.html#_Enhance.enhance)¶ Returns an enhanced image. Parameters: **factor** – A floating point value controlling the enhancement. Factor 1.0 always returns a copy of the original image, lower factors mean less color (brightness, contrast, etc), and higher values more. There are no restrictions on this value. class PIL.ImageEnhance.Color(_image_)[[source]](../_modules/PIL/ImageEnhance.html#Color)¶ Adjust image color balance. This class can be used to adjust the colour balance of an image, in a manner similar to the controls on a colour TV set. An enhancement factor of 0.0 gives a black and white image. A factor of 1.0 gives the original image. class PIL.ImageEnhance.Contrast(_image_)[[source]](../_modules/PIL/ImageEnhance.html#Contrast)¶ Adjust image contrast. This class can be used to control the contrast of an image, similar to the contrast control on a TV set. An enhancement factor of 0.0 gives a solid gray image, a factor of 1.0 gives the original image, and greater values increase the contrast of the image. class PIL.ImageEnhance.Brightness(_image_)[[source]](../_modules/PIL/ImageEnhance.html#Brightness)¶ Adjust image brightness. This class can be used to control the brightness of an image. An enhancement factor of 0.0 gives a black image, a factor of 1.0 gives the original image, and greater values increase the brightness of the image. class PIL.ImageEnhance.Sharpness(_image_)[[source]](../_modules/PIL/ImageEnhance.html#Sharpness)¶ Adjust image sharpness. This class can be used to adjust the sharpness of an image. An enhancement factor of 0.0 gives a blurred image, a factor of 1.0 gives the original image, and a factor of 2.0 gives a sharpened image. [ Next `ImageFile` module ](ImageFile.html) [ Previous `ImageDraw` module ](ImageDraw.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImageEnhance` module * Example: Vary the sharpness of an image * Classes * `_Enhance` * `_Enhance.enhance()` * `Color` * `Contrast` * `Brightness` * `Sharpness` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImageFile.html # Path: reference/ImageFile.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * `ImageFile` module * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImageFile.rst.txt "View this page") # `ImageFile` module¶ The `ImageFile` module provides support functions for the image open and save functions. In addition, it provides a `Parser` class which can be used to decode an image piece by piece (e.g. while receiving it over a network connection). This class implements the same consumer interface as the standard **sgmllib** and **xmllib** modules. ## Example: Parse an image¶ from PIL import ImageFile fp = open("hopper.ppm", "rb") p = ImageFile.Parser() while 1: s = fp.read(1024) if not s: break p.feed(s) im = p.close() im.save("copy.jpg") ## Classes¶ class PIL.ImageFile._Tile[[source]](../_modules/PIL/ImageFile.html#_Tile)¶ Bases: [`NamedTuple`](https://docs.python.org/3/library/typing.html#typing.NamedTuple "\(in Python v3.14\)") _Tile(codec_name, extents, offset, args) codec_name: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")¶ Alias for field number 0 extents: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ Alias for field number 1 offset: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ Alias for field number 2 args: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)"), ...] | [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ Alias for field number 3 class PIL.ImageFile.Parser[[source]](../_modules/PIL/ImageFile.html#Parser)¶ Incremental image parser. This class implements the standard feed/close consumer interface. close() -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageFile.html#Parser.close)¶ (Consumer) Close the stream. Returns: An image object. Raises: [**OSError**](https://docs.python.org/3/library/exceptions.html#OSError "\(in Python v3.14\)") – If the parser failed to parse the image file either because it cannot be identified or cannot be decoded. feed(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFile.html#Parser.feed)¶ (Consumer) Feed data to the parser. Parameters: **data** – A string buffer. Raises: [**OSError**](https://docs.python.org/3/library/exceptions.html#OSError "\(in Python v3.14\)") – If the parser failed to parse the image file. reset() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFile.html#Parser.reset)¶ (Consumer) Reset the parser. Note that you can only call this method immediately after you’ve created a parser; parser instances cannot be reused. class PIL.ImageFile.PyCodec[[source]](../_modules/PIL/ImageFile.html#PyCodec)¶ cleanup() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFile.html#PyCodec.cleanup)¶ Override to perform codec specific cleanup Returns: None init(_args : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)"), ...]_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFile.html#PyCodec.init)¶ Override to perform codec specific initialization Parameters: **args** – Tuple of arg items from the tile entry Returns: None setfd(_fd : [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFile.html#PyCodec.setfd)¶ Called from ImageFile to set the Python file-like object Parameters: **fd** – A Python file-like object Returns: None setimage(_im : [Image.core.ImagingCore](internal_modules.html#PIL.Image.core.ImagingCore "PIL.Image.core.ImagingCore")_, _extents : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFile.html#PyCodec.setimage)¶ Called from ImageFile to set the core output image for the codec Parameters: * **im** – A core image object * **extents** – a 4 tuple of (x0, y0, x1, y1) defining the rectangle for this tile Returns: None class PIL.ImageFile.PyDecoder[[source]](../_modules/PIL/ImageFile.html#PyDecoder)¶ Bases: `PyCodec` Python implementation of a format decoder. Override this class and add the decoding logic in the `decode()` method. See [Writing Your Own File Codec in Python](../handbook/writing-your-own- image-plugin.html#file-codecs-py) decode(_buffer : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [SupportsArrayInterface](Image.html#PIL.Image.SupportsArrayInterface "PIL.Image.SupportsArrayInterface")_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/ImageFile.html#PyDecoder.decode)¶ Override to perform the decoding process. Parameters: **buffer** – A bytes object with the data to be decoded. Returns: A tuple of `(bytes consumed, errcode)`. If finished with decoding return -1 for the bytes consumed. Err codes are from `ImageFile.ERRORS`. set_as_raw(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _rawmode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _extra : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)"), ...] = ()_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFile.html#PyDecoder.set_as_raw)¶ Convenience method to set the internal image from a stream of raw data Parameters: * **data** – Bytes to be set * **rawmode** – The rawmode to be used for the decoder. If not specified, it will default to the mode of the image * **extra** – Extra arguments for the decoder. Returns: None class PIL.ImageFile.PyEncoder[[source]](../_modules/PIL/ImageFile.html#PyEncoder)¶ Bases: `PyCodec` Python implementation of a format encoder. Override this class and add the decoding logic in the `encode()` method. See [Writing Your Own File Codec in Python](../handbook/writing-your-own- image-plugin.html#file-codecs-py) encode(_bufsize : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")][[source]](../_modules/PIL/ImageFile.html#PyEncoder.encode)¶ Override to perform the encoding process. Parameters: **bufsize** – Buffer size. Returns: A tuple of `(bytes encoded, errcode, bytes)`. If finished with encoding return 1 for the error code. Err codes are from `ImageFile.ERRORS`. encode_to_file(_fh : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _bufsize : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFile.html#PyEncoder.encode_to_file)¶ Parameters: * **fh** – File handle. * **bufsize** – Buffer size. Returns: If finished successfully, return 0. Otherwise, return an error code. Err codes are from `ImageFile.ERRORS`. encode_to_pyfd() -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/ImageFile.html#PyEncoder.encode_to_pyfd)¶ If `pushes_fd` is `True`, then this method will be used, and `encode()` will only be called once. Returns: A tuple of `(bytes consumed, errcode)`. Err codes are from `ImageFile.ERRORS`. class PIL.ImageFile.ImageFile[[source]](../_modules/PIL/ImageFile.html#ImageFile)¶ Bases: [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") Base class for image file format handlers. custom_mimetype: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ tile: [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[_Tile]¶ A list of tile descriptors decoderconfig: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[Any, ...]¶ close() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFile.html#ImageFile.close)¶ Closes the file pointer, if possible. This operation will destroy the image core and release its memory. The image data will be unusable afterward. This function is required to close images that have multiple frames or have not had their file read and closed by the [`load()`](Image.html#PIL.Image.Image.load "PIL.Image.Image.load") method. See [File handling in Pillow](open_files.html#file-handling) for more information. get_child_images() -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[ImageFile][[source]](../_modules/PIL/ImageFile.html#ImageFile.get_child_images)¶ get_format_mimetype() -> [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFile.html#ImageFile.get_format_mimetype)¶ verify() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFile.html#ImageFile.verify)¶ Check file integrity load() -> [Image.core.PixelAccess](PixelAccess.html#PixelAccess "PIL.Image.core.PixelAccess") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFile.html#ImageFile.load)¶ Load image data based on tile list load_prepare() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFile.html#ImageFile.load_prepare)¶ load_end() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFile.html#ImageFile.load_end)¶ class PIL.ImageFile.StubHandler[[source]](../_modules/PIL/ImageFile.html#StubHandler)¶ Bases: [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC "\(in Python v3.14\)") class PIL.ImageFile.StubImageFile[[source]](../_modules/PIL/ImageFile.html#StubImageFile)¶ Bases: `ImageFile` Base class for stub image loaders. A stub loader is an image loader that can identify files of a certain format, but relies on external code to load the file. load() -> [Image.core.PixelAccess](PixelAccess.html#PixelAccess "PIL.Image.core.PixelAccess") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFile.html#StubImageFile.load)¶ Load image data based on tile list ## Constants¶ PIL.ImageFile.LOAD_TRUNCATED_IMAGES = False¶ Whether or not to load truncated image files. User code may change this. PIL.ImageFile.MAXBLOCK = 65536¶ By default, Pillow processes image data in blocks. This helps to prevent excessive use of resources. Codecs may disable this behaviour with `_pulls_fd` or `_pushes_fd`. When reading an image, this is the number of bytes to read at once. When writing an image, this is the number of bytes to write at once. If the image width times 4 is greater, then that will be used instead. Plugins may also set a greater number. User code may set this to another number. PIL.ImageFile.ERRORS¶ Dict of known error codes returned from `PyDecoder.decode()`, `PyEncoder.encode()` `PyEncoder.encode_to_pyfd()` and `PyEncoder.encode_to_file()`. [ Next `ImageFilter` module ](ImageFilter.html) [ Previous `ImageEnhance` module ](ImageEnhance.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImageFile` module * Example: Parse an image * Classes * `_Tile` * `_Tile.codec_name` * `_Tile.extents` * `_Tile.offset` * `_Tile.args` * `Parser` * `Parser.close()` * `Parser.feed()` * `Parser.reset()` * `PyCodec` * `PyCodec.cleanup()` * `PyCodec.init()` * `PyCodec.setfd()` * `PyCodec.setimage()` * `PyDecoder` * `PyDecoder.decode()` * `PyDecoder.set_as_raw()` * `PyEncoder` * `PyEncoder.encode()` * `PyEncoder.encode_to_file()` * `PyEncoder.encode_to_pyfd()` * `ImageFile` * `ImageFile.custom_mimetype` * `ImageFile.tile` * `ImageFile.decoderconfig` * `ImageFile.close()` * `ImageFile.get_child_images()` * `ImageFile.get_format_mimetype()` * `ImageFile.verify()` * `ImageFile.load()` * `ImageFile.load_prepare()` * `ImageFile.load_end()` * `StubHandler` * `StubImageFile` * `StubImageFile.load()` * Constants * `LOAD_TRUNCATED_IMAGES` * `MAXBLOCK` * `ERRORS` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImageFilter.html # Path: reference/ImageFilter.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * `ImageFilter` module * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImageFilter.rst.txt "View this page") # `ImageFilter` module¶ The `ImageFilter` module contains definitions for a pre-defined set of filters, which can be be used with the [`Image.filter()`](Image.html#PIL.Image.Image.filter "PIL.Image.Image.filter") method. ## Example: Filter an image¶ from PIL import ImageFilter im1 = im.filter(ImageFilter.BLUR) im2 = im.filter(ImageFilter.MinFilter(3)) im3 = im.filter(ImageFilter.MinFilter) # same as MinFilter(3) ## Filters¶ Pillow provides the following set of predefined image enhancement filters: * **BLUR** * **CONTOUR** * **DETAIL** * **EDGE_ENHANCE** * **EDGE_ENHANCE_MORE** * **EMBOSS** * **FIND_EDGES** * **SHARPEN** * **SMOOTH** * **SMOOTH_MORE** class PIL.ImageFilter.Color3DLUT(_size : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _table : Sequence[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] | Sequence[Sequence[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]] | [NumpyArray](internal_modules.html#PIL._typing.NumpyArray "PIL._typing.NumpyArray")_, _channels : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 3_, _target_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _** kwargs: [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)")_)[[source]](../_modules/PIL/ImageFilter.html#Color3DLUT)¶ Three-dimensional color lookup table. Transforms 3-channel pixels using the values of the channels as coordinates in the 3D lookup table and interpolating the nearest elements. This method allows you to apply almost any color transformation in constant time by using pre-calculated decimated tables. Added in version 5.2.0. Parameters: * **size** – Size of the table. One int or tuple of (int, int, int). Minimal size in any dimension is 2, maximum is 65. * **table** – Flat lookup table. A list of `channels * size**3` float elements or a list of `size**3` channels-sized tuples with floats. Channels are changed first, then first dimension, then second, then third. Value 0.0 corresponds lowest value of output, 1.0 highest. * **channels** – Number of channels in the table. Could be 3 or 4. Default is 3. * **target_mode** – A mode for the result image. Should have not less than `channels` channels. Default is `None`, which means that mode wouldn’t be changed. classmethod generate(_size : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _callback : Callable[[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), ...]]_, _channels : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 3_, _target_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> Color3DLUT[[source]](../_modules/PIL/ImageFilter.html#Color3DLUT.generate)¶ Generates new LUT using provided callback. Parameters: * **size** – Size of the table. Passed to the constructor. * **callback** – Function with three parameters which correspond three color channels. Will be called `size**3` times with values from 0.0 to 1.0 and should return a tuple with `channels` elements. * **channels** – The number of channels which should return callback. * **target_mode** – Passed to the constructor of the resulting lookup table. transform(_callback : Callable[..., [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), ...]]_, _with_normals : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = False_, _channels : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _target_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> Color3DLUT[[source]](../_modules/PIL/ImageFilter.html#Color3DLUT.transform)¶ Transforms the table values using provided callback and returns a new LUT with altered values. Parameters: * **callback** – A function which takes old lookup table values and returns a new set of values. The number of arguments which function should take is `self.channels` or `3 + self.channels` if `with_normals` flag is set. Should return a tuple of `self.channels` or `channels` elements if it is set. * **with_normals** – If true, `callback` will be called with coordinates in the color cube as the first three arguments. Otherwise, `callback` will be called only with actual color values. * **channels** – The number of channels in the resulting lookup table. * **target_mode** – Passed to the constructor of the resulting lookup table. class PIL.ImageFilter.BoxBlur(_radius : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]_)[[source]](../_modules/PIL/ImageFilter.html#BoxBlur)¶ Blurs the image by setting each pixel to the average value of the pixels in a square box extending radius pixels in each direction. Supports float radius of arbitrary size. Uses an optimized implementation which runs in linear time relative to the size of the image for any radius value. Parameters: **radius** – Size of the box in a direction. Either a sequence of two numbers for x and y, or a single number for both. Radius 0 does not blur, returns an identical image. Radius 1 takes 1 pixel in each direction, i.e. 9 pixels in total. class PIL.ImageFilter.GaussianBlur(_radius : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] = 2_)[[source]](../_modules/PIL/ImageFilter.html#GaussianBlur)¶ Blurs the image with a sequence of extended box filters, which approximates a Gaussian kernel. For details on accuracy see <> Parameters: **radius** – Standard deviation of the Gaussian kernel. Either a sequence of two numbers for x and y, or a single number for both. class PIL.ImageFilter.UnsharpMask(_radius : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") = 2_, _percent : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 150_, _threshold : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 3_)[[source]](../_modules/PIL/ImageFilter.html#UnsharpMask)¶ Unsharp mask filter. See Wikipedia’s entry on [digital unsharp masking](https://en.wikipedia.org/wiki/Unsharp_masking#Digital_unsharp_masking) for an explanation of the parameters. Parameters: * **radius** – Blur Radius * **percent** – Unsharp strength, in percent * **threshold** – Threshold controls the minimum brightness change that will be sharpened class PIL.ImageFilter.Kernel(_size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _kernel : [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]_, _scale : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _offset : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") = 0_)[[source]](../_modules/PIL/ImageFilter.html#Kernel)¶ Create a convolution kernel. This only supports 3x3 and 5x5 integer and floating point kernels. Kernels can only be applied to “L” and “RGB” images. Parameters: * **size** – Kernel size, given as (width, height). This must be (3,3) or (5,5). * **kernel** – A sequence containing kernel weights. The kernel will be flipped vertically before being applied to the image. * **scale** – Scale factor. If given, the result for each pixel is divided by this value. The default is the sum of the kernel weights. * **offset** – Offset. If given, this value is added to the result, after it has been divided by the scale factor. class PIL.ImageFilter.RankFilter(_size : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _rank : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_)[[source]](../_modules/PIL/ImageFilter.html#RankFilter)¶ Create a rank filter. The rank filter sorts all pixels in a window of the given size, and returns the `rank`’th value. Parameters: * **size** – The kernel size, in pixels. * **rank** – What pixel value to pick. Use 0 for a min filter, `size * size / 2` for a median filter, `size * size - 1` for a max filter, etc. class PIL.ImageFilter.MedianFilter(_size : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 3_)[[source]](../_modules/PIL/ImageFilter.html#MedianFilter)¶ Create a median filter. Picks the median pixel value in a window with the given size. Parameters: **size** – The kernel size, in pixels. class PIL.ImageFilter.MinFilter(_size : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 3_)[[source]](../_modules/PIL/ImageFilter.html#MinFilter)¶ Create a min filter. Picks the lowest pixel value in a window with the given size. Parameters: **size** – The kernel size, in pixels. class PIL.ImageFilter.MaxFilter(_size : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 3_)[[source]](../_modules/PIL/ImageFilter.html#MaxFilter)¶ Create a max filter. Picks the largest pixel value in a window with the given size. Parameters: **size** – The kernel size, in pixels. class PIL.ImageFilter.ModeFilter(_size : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 3_)[[source]](../_modules/PIL/ImageFilter.html#ModeFilter)¶ Create a mode filter. Picks the most frequent pixel value in a box with the given size. Pixel values that occur only once or twice are ignored; if no pixel value occurs more than twice, the original pixel value is preserved. Parameters: **size** – The kernel size, in pixels. class PIL.ImageFilter.Filter[[source]](../_modules/PIL/ImageFilter.html#Filter)¶ An abstract mixin used for filtering images (for use with [`filter()`](Image.html#PIL.Image.Image.filter "PIL.Image.Image.filter")). Implementors must provide the following method: filter(_self_ , _image_)[[source]](../_modules/PIL/ImageFilter.html#Filter.filter)¶ Applies a filter to a single-band image, or a single band of an image. Returns: A filtered copy of the image. class PIL.ImageFilter.MultibandFilter[[source]](../_modules/PIL/ImageFilter.html#MultibandFilter)¶ An abstract mixin used for filtering multi-band images (for use with [`filter()`](Image.html#PIL.Image.Image.filter "PIL.Image.Image.filter")). Implementors must provide the following method: filter(_self_ , _image_)¶ Applies a filter to a multi-band image. Returns: A filtered copy of the image. [ Next `ImageFont` module ](ImageFont.html) [ Previous `ImageFile` module ](ImageFile.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImageFilter` module * Example: Filter an image * Filters * `Color3DLUT` * `Color3DLUT.generate()` * `Color3DLUT.transform()` * `BoxBlur` * `GaussianBlur` * `UnsharpMask` * `Kernel` * `RankFilter` * `MedianFilter` * `MinFilter` * `MaxFilter` * `ModeFilter` * `Filter` * `Filter.filter()` * `MultibandFilter` * `MultibandFilter.filter()` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImageFont.html # Path: reference/ImageFont.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * `ImageFont` module * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImageFont.rst.txt "View this page") # `ImageFont` module¶ The `ImageFont` module defines a class with the same name. Instances of this class store bitmap fonts, and are used with the [`PIL.ImageDraw.ImageDraw.text()`](ImageDraw.html#PIL.ImageDraw.ImageDraw.text "PIL.ImageDraw.ImageDraw.text") method. PIL uses its own font file format to store bitmap fonts, limited to 256 characters. You can use [pilfont.py](https://github.com/python-pillow/pillow- scripts/blob/main/Scripts/pilfont.py) from [pillow- scripts](https://pypi.org/project/pillow-scripts/) to convert BDF and PCF font descriptors (X window font formats) to this format. Starting with version 1.1.4, PIL can be configured to support TrueType and OpenType fonts (as well as other font formats supported by the FreeType library). For earlier versions, TrueType support is only available as part of the imToolkit package. When measuring text sizes, this module will not break at newline characters. For multiline text, see the [`ImageDraw`](ImageDraw.html#module-PIL.ImageDraw "PIL.ImageDraw") module. Warning To protect against potential DOS attacks when using arbitrary strings as text input, Pillow will raise a [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "\(in Python v3.14\)") if the number of characters is over a certain limit, `MAX_STRING_LENGTH`. This threshold can be changed by setting `MAX_STRING_LENGTH`. It can be disabled by setting `ImageFont.MAX_STRING_LENGTH = None`. ## Example¶ from PIL import ImageFont, ImageDraw draw = ImageDraw.Draw(image) # use a bitmap font font = ImageFont.load("arial.pil") draw.text((10, 10), "hello", font=font) # use a truetype font font = ImageFont.truetype("arial.ttf", 15) draw.text((10, 25), "world", font=font) ## Functions¶ PIL.ImageFont.load(_filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> ImageFont[[source]](../_modules/PIL/ImageFont.html#load)¶ Load a font file. This function loads a font object from the given bitmap font file, and returns the corresponding font object. For loading TrueType or OpenType fonts instead, see `truetype()`. Parameters: **filename** – Name of font file. Returns: A font object. Raises: [**OSError**](https://docs.python.org/3/library/exceptions.html#OSError "\(in Python v3.14\)") – If the file could not be read. PIL.ImageFont.load_path(_filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_) -> ImageFont[[source]](../_modules/PIL/ImageFont.html#load_path)¶ Load font file. Same as `load()`, but searches for a bitmap font along the Python path. Parameters: **filename** – Name of font file. Returns: A font object. Raises: [**OSError**](https://docs.python.org/3/library/exceptions.html#OSError "\(in Python v3.14\)") – If the file could not be read. PIL.ImageFont.truetype(_font : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [PathLike](https://docs.python.org/3/library/os.html#os.PathLike "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")] | [PathLike](https://docs.python.org/3/library/os.html#os.PathLike "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | [BinaryIO](https://docs.python.org/3/library/typing.html#typing.BinaryIO "\(in Python v3.14\)")_, _size : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") = 10_, _index : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 0_, _encoding : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") = ''_, _layout_engine : Layout | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> FreeTypeFont[[source]](../_modules/PIL/ImageFont.html#truetype)¶ Load a TrueType or OpenType font from a file or file-like object, and create a font object. This function loads a font object from the given file or file- like object, and creates a font object for a font of the given size. For loading bitmap fonts instead, see `load()` and `load_path()`. Pillow uses FreeType to open font files. On Windows, be aware that FreeType will keep the file open as long as the FreeTypeFont object exists. Windows limits the number of files that can be open in C at once to 512, so if many fonts are opened simultaneously and that limit is approached, an `OSError` may be thrown, reporting that FreeType “cannot open resource”. A workaround would be to copy the file(s) into memory, and open that instead. This function requires the _imagingft service. Parameters: * **font** – A filename or file-like object containing a TrueType font. If the file is not found in this filename, the loader may also search in other directories, such as: * The `fonts/` directory on Windows, * `/Library/Fonts/`, `/System/Library/Fonts/` and `~/Library/Fonts/` on macOS. * `~/.local/share/fonts`, `/usr/local/share/fonts`, and `/usr/share/fonts` on Linux; or those specified by the `XDG_DATA_HOME` and `XDG_DATA_DIRS` environment variables for user-installed and system-wide fonts, respectively. * **size** – The requested size, in pixels. * **index** – Which font face to load (default is first available face). * **encoding** – Which font encoding to use (default is Unicode). Possible encodings include (see the FreeType documentation for more information): * ”unic” (Unicode) * ”symb” (Microsoft Symbol) * ”ADOB” (Adobe Standard) * ”ADBE” (Adobe Expert) * ”ADBC” (Adobe Custom) * ”armn” (Apple Roman) * ”sjis” (Shift JIS) * ”gb “ (PRC) * ”big5” * ”wans” (Extended Wansung) * ”joha” (Johab) * ”lat1” (Latin-1) This specifies the character set to use. It does not alter the encoding of any text provided in subsequent operations. * **layout_engine** – Which layout engine to use, if available: `ImageFont.Layout.BASIC` or `ImageFont.Layout.RAQM`. If it is available, Raqm layout will be used by default. Otherwise, basic layout will be used. Raqm layout is recommended for all non-English text. If Raqm layout is not required, basic layout will have better performance. You can check support for Raqm layout using [`PIL.features.check_feature()`](features.html#PIL.features.check_feature "PIL.features.check_feature") with `feature="raqm"`. Added in version 4.2.0. Returns: A font object. Raises: * [**OSError**](https://docs.python.org/3/library/exceptions.html#OSError "\(in Python v3.14\)") – If the file could not be read. * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "\(in Python v3.14\)") – If the font size is not greater than zero. PIL.ImageFont.load_default(_size : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> FreeTypeFont | ImageFont[[source]](../_modules/PIL/ImageFont.html#load_default)¶ If FreeType support is available, load a version of Aileron Regular, , with a more limited character set. Otherwise, load a “better than nothing” font. Added in version 1.1.4. Parameters: **size** – The font size of Aileron Regular. Added in version 10.1.0. Returns: A font object. PIL.ImageFont.load_default_imagefont() -> ImageFont[[source]](../_modules/PIL/ImageFont.html#load_default_imagefont)¶ ## Methods¶ class PIL.ImageFont.ImageFont[[source]](../_modules/PIL/ImageFont.html#ImageFont)¶ PIL font wrapper getbbox(_text : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [bytearray](https://docs.python.org/3/library/stdtypes.html#bytearray "\(in Python v3.14\)")_, _* args: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_, _** kwargs: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/ImageFont.html#ImageFont.getbbox)¶ Returns bounding box (in pixels) of given text. Added in version 9.2.0. Parameters: **text** – Text to render. Returns: `(left, top, right, bottom)` bounding box getlength(_text : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [bytearray](https://docs.python.org/3/library/stdtypes.html#bytearray "\(in Python v3.14\)")_, _* args: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_, _** kwargs: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_) -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFont.html#ImageFont.getlength)¶ Returns length (in pixels) of given text. This is the amount by which following text should be offset. Added in version 9.2.0. getmask(_text : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") = ''_, _* args: Any_, _** kwargs: Any_) -> [Image.core.ImagingCore](internal_modules.html#PIL.Image.core.ImagingCore "PIL.Image.core.ImagingCore")[[source]](../_modules/PIL/ImageFont.html#ImageFont.getmask)¶ Create a bitmap for the text. If the font uses antialiasing, the bitmap should have mode `L` and use a maximum value of 255. Otherwise, it should have mode `1`. Parameters: * **text** – Text to render. * **mode** – Used by some graphics drivers to indicate what mode the driver prefers; if empty, the renderer may return either mode. Note that the mode is always a string, to simplify C-level implementations. Added in version 1.1.5. Returns: An internal PIL storage memory instance as defined by the [`PIL.Image.core`](internal_modules.html#module-PIL.Image.core "PIL.Image.core") interface module. class PIL.ImageFont.FreeTypeFont(_font : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [PathLike](https://docs.python.org/3/library/os.html#os.PathLike "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")] | [PathLike](https://docs.python.org/3/library/os.html#os.PathLike "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | [BinaryIO](https://docs.python.org/3/library/typing.html#typing.BinaryIO "\(in Python v3.14\)")_, _size : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") = 10_, _index : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 0_, _encoding : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") = ''_, _layout_engine : Layout | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/ImageFont.html#FreeTypeFont)¶ FreeType font wrapper (requires _imagingft service) font_variant(_font : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [PathLike](https://docs.python.org/3/library/os.html#os.PathLike "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")] | [PathLike](https://docs.python.org/3/library/os.html#os.PathLike "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | [BinaryIO](https://docs.python.org/3/library/typing.html#typing.BinaryIO "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _size : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _index : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _encoding : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _layout_engine : Layout | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> FreeTypeFont[[source]](../_modules/PIL/ImageFont.html#FreeTypeFont.font_variant)¶ Create a copy of this FreeTypeFont object, using any specified arguments to override the settings. Parameters are identical to the parameters used to initialize this object. Returns: A FreeTypeFont object. get_variation_axes() -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[Axis][[source]](../_modules/PIL/ImageFont.html#FreeTypeFont.get_variation_axes)¶ Returns: A list of the axes in a variation font. Raises: [**OSError**](https://docs.python.org/3/library/exceptions.html#OSError "\(in Python v3.14\)") – If the font is not a variation font. get_variation_names() -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")][[source]](../_modules/PIL/ImageFont.html#FreeTypeFont.get_variation_names)¶ Returns: A list of the named styles in a variation font. Raises: [**OSError**](https://docs.python.org/3/library/exceptions.html#OSError "\(in Python v3.14\)") – If the font is not a variation font. getbbox(_text : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") = ''_, _direction : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _features : [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _language : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _stroke_width : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") = 0_, _anchor : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")][[source]](../_modules/PIL/ImageFont.html#FreeTypeFont.getbbox)¶ Returns bounding box (in pixels) of given text relative to given anchor when rendered in font with provided direction, features, and language. Use `getlength()` to get the offset of following text with 1/64 pixel precision. The bounding box includes extra margins for some fonts, e.g. italics or accents. Added in version 8.0.0. Parameters: * **text** – Text to render. * **mode** – Used by some graphics drivers to indicate what mode the driver prefers; if empty, the renderer may return either mode. Note that the mode is always a string, to simplify C-level implementations. * **direction** – Direction of the text. It can be ‘rtl’ (right to left), ‘ltr’ (left to right) or ‘ttb’ (top to bottom). Requires libraqm. * **features** – A list of OpenType font features to be used during text layout. This is usually used to turn on optional font features that are not enabled by default, for example ‘dlig’ or ‘ss01’, but can be also used to turn off default font features for example ‘-liga’ to disable ligatures or ‘-kern’ to disable kerning. To get all supported features, see Requires libraqm. * **language** – Language of the text. Different languages may use different glyph shapes or ligatures. This parameter tells the font which language the text is in, and to apply the correct substitutions as appropriate, if available. It should be a [BCP 47 language code](https://www.w3.org/International/articles/language-tags/) Requires libraqm. * **stroke_width** – The width of the text stroke. * **anchor** – The text anchor alignment. Determines the relative location of the anchor to the text. The default alignment is top left, specifically `la` for horizontal text and `lt` for vertical text. See [Text anchors](../handbook/text-anchors.html#text-anchors) for details. Returns: `(left, top, right, bottom)` bounding box getlength(_text : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") = ''_, _direction : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _features : [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _language : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFont.html#FreeTypeFont.getlength)¶ Returns length (in pixels with 1/64 precision) of given text when rendered in font with provided direction, features, and language. This is the amount by which following text should be offset. Text bounding box may extend past the length in some fonts, e.g. when using italics or accents. The result is returned as a float; it is a whole number if using basic layout. Note that the sum of two lengths may not equal the length of a concatenated string due to kerning. If you need to adjust for kerning, include the following character and subtract its length. For example, instead of hello = font.getlength("Hello") world = font.getlength("World") hello_world = hello + world # not adjusted for kerning assert hello_world == font.getlength("HelloWorld") # may fail use hello = font.getlength("HelloW") - font.getlength("W") # adjusted for kerning world = font.getlength("World") hello_world = hello + world # adjusted for kerning assert hello_world == font.getlength("HelloWorld") # True or disable kerning with (requires libraqm) hello = draw.textlength("Hello", font, features=["-kern"]) world = draw.textlength("World", font, features=["-kern"]) hello_world = hello + world # kerning is disabled, no need to adjust assert hello_world == draw.textlength("HelloWorld", font, features=["-kern"]) Added in version 8.0.0. Parameters: * **text** – Text to measure. * **mode** – Used by some graphics drivers to indicate what mode the driver prefers; if empty, the renderer may return either mode. Note that the mode is always a string, to simplify C-level implementations. * **direction** – Direction of the text. It can be ‘rtl’ (right to left), ‘ltr’ (left to right) or ‘ttb’ (top to bottom). Requires libraqm. * **features** – A list of OpenType font features to be used during text layout. This is usually used to turn on optional font features that are not enabled by default, for example ‘dlig’ or ‘ss01’, but can be also used to turn off default font features for example ‘-liga’ to disable ligatures or ‘-kern’ to disable kerning. To get all supported features, see Requires libraqm. * **language** – Language of the text. Different languages may use different glyph shapes or ligatures. This parameter tells the font which language the text is in, and to apply the correct substitutions as appropriate, if available. It should be a [BCP 47 language code](https://www.w3.org/International/articles/language- tags/) Requires libraqm. Returns: Either width for horizontal text, or height for vertical text. getmask(_text : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") = ''_, _direction : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _features : [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _language : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _stroke_width : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") = 0_, _anchor : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _ink : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 0_, _start : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [Image.core.ImagingCore](internal_modules.html#PIL.Image.core.ImagingCore "PIL.Image.core.ImagingCore")[[source]](../_modules/PIL/ImageFont.html#FreeTypeFont.getmask)¶ Create a bitmap for the text. If the font uses antialiasing, the bitmap should have mode `L` and use a maximum value of 255. If the font has embedded color data, the bitmap should have mode `RGBA`. Otherwise, it should have mode `1`. Parameters: * **text** – Text to render. * **mode** – Used by some graphics drivers to indicate what mode the driver prefers; if empty, the renderer may return either mode. Note that the mode is always a string, to simplify C-level implementations. Added in version 1.1.5. * **direction** – Direction of the text. It can be ‘rtl’ (right to left), ‘ltr’ (left to right) or ‘ttb’ (top to bottom). Requires libraqm. Added in version 4.2.0. * **features** – A list of OpenType font features to be used during text layout. This is usually used to turn on optional font features that are not enabled by default, for example ‘dlig’ or ‘ss01’, but can be also used to turn off default font features for example ‘-liga’ to disable ligatures or ‘-kern’ to disable kerning. To get all supported features, see Requires libraqm. Added in version 4.2.0. * **language** – Language of the text. Different languages may use different glyph shapes or ligatures. This parameter tells the font which language the text is in, and to apply the correct substitutions as appropriate, if available. It should be a [BCP 47 language code](https://www.w3.org/International/articles/language- tags/) Requires libraqm. Added in version 6.0.0. * **stroke_width** – The width of the text stroke. Added in version 6.2.0. * **anchor** – The text anchor alignment. Determines the relative location of the anchor to the text. The default alignment is top left, specifically `la` for horizontal text and `lt` for vertical text. See [Text anchors](../handbook/text- anchors.html#text-anchors) for details. > Added in version 8.0.0. * **ink** – Foreground ink for rendering in RGBA mode. Added in version 8.0.0. * **start** – Tuple of horizontal and vertical offset, as text may render differently when starting at fractional coordinates. > Added in version 9.4.0. Returns: An internal PIL storage memory instance as defined by the [`PIL.Image.core`](internal_modules.html#module-PIL.Image.core "PIL.Image.core") interface module. getmask2(_text : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") = ''_, _direction : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _features : [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _language : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _stroke_width : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") = 0_, _anchor : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _ink : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 0_, _start : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _* args: Any_, _** kwargs: Any_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[Image.core.ImagingCore](internal_modules.html#PIL.Image.core.ImagingCore "PIL.Image.core.ImagingCore"), [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]][[source]](../_modules/PIL/ImageFont.html#FreeTypeFont.getmask2)¶ Create a bitmap for the text. If the font uses antialiasing, the bitmap should have mode `L` and use a maximum value of 255. If the font has embedded color data, the bitmap should have mode `RGBA`. Otherwise, it should have mode `1`. Parameters: * **text** – Text to render. * **mode** – Used by some graphics drivers to indicate what mode the driver prefers; if empty, the renderer may return either mode. Note that the mode is always a string, to simplify C-level implementations. Added in version 1.1.5. * **direction** – Direction of the text. It can be ‘rtl’ (right to left), ‘ltr’ (left to right) or ‘ttb’ (top to bottom). Requires libraqm. Added in version 4.2.0. * **features** – A list of OpenType font features to be used during text layout. This is usually used to turn on optional font features that are not enabled by default, for example ‘dlig’ or ‘ss01’, but can be also used to turn off default font features for example ‘-liga’ to disable ligatures or ‘-kern’ to disable kerning. To get all supported features, see Requires libraqm. Added in version 4.2.0. * **language** – Language of the text. Different languages may use different glyph shapes or ligatures. This parameter tells the font which language the text is in, and to apply the correct substitutions as appropriate, if available. It should be a [BCP 47 language code](https://www.w3.org/International/articles/language- tags/) Requires libraqm. Added in version 6.0.0. * **stroke_width** – The width of the text stroke. Added in version 6.2.0. * **anchor** – The text anchor alignment. Determines the relative location of the anchor to the text. The default alignment is top left, specifically `la` for horizontal text and `lt` for vertical text. See [Text anchors](../handbook/text- anchors.html#text-anchors) for details. > Added in version 8.0.0. * **ink** – Foreground ink for rendering in RGBA mode. Added in version 8.0.0. * **start** – Tuple of horizontal and vertical offset, as text may render differently when starting at fractional coordinates. > Added in version 9.4.0. Returns: A tuple of an internal PIL storage memory instance as defined by the [`PIL.Image.core`](internal_modules.html#module-PIL.Image.core "PIL.Image.core") interface module, and the text offset, the gap between the starting coordinate and the first marking getmetrics() -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/ImageFont.html#FreeTypeFont.getmetrics)¶ Returns: A tuple of the font ascent (the distance from the baseline to the highest outline point) and descent (the distance from the baseline to the lowest outline point, a negative value) getname() -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)"), [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")][[source]](../_modules/PIL/ImageFont.html#FreeTypeFont.getname)¶ Returns: A tuple of the font family (e.g. Helvetica) and the font style (e.g. Bold) set_variation_by_axes(_axes : [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFont.html#FreeTypeFont.set_variation_by_axes)¶ Parameters: **axes** – A list of values for each axis. Raises: [**OSError**](https://docs.python.org/3/library/exceptions.html#OSError "\(in Python v3.14\)") – If the font is not a variation font. set_variation_by_name(_name : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFont.html#FreeTypeFont.set_variation_by_name)¶ Parameters: **name** – The name of the style. Raises: [**OSError**](https://docs.python.org/3/library/exceptions.html#OSError "\(in Python v3.14\)") – If the font is not a variation font. class PIL.ImageFont.TransposedFont(_font : ImageFont | FreeTypeFont_, _orientation : [Transpose](Image.html#PIL.Image.Transpose "PIL.Image.Transpose") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/ImageFont.html#TransposedFont)¶ Wrapper for writing rotated or mirrored text getbbox(_text : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _* args: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_, _** kwargs: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")][[source]](../_modules/PIL/ImageFont.html#TransposedFont.getbbox)¶ getlength(_text : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _* args: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_, _** kwargs: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_) -> [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageFont.html#TransposedFont.getlength)¶ getmask(_text : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") = ''_, _* args: Any_, _** kwargs: Any_) -> [Image.core.ImagingCore](internal_modules.html#PIL.Image.core.ImagingCore "PIL.Image.core.ImagingCore")[[source]](../_modules/PIL/ImageFont.html#TransposedFont.getmask)¶ ## Constants¶ class PIL.ImageFont.Layout[[source]](../_modules/PIL/ImageFont.html#Layout)¶ BASIC¶ Use basic text layout for TrueType font. Advanced features such as text direction are not supported. RAQM¶ Use Raqm text layout for TrueType font. Advanced features are supported. Requires Raqm, you can check support using [`PIL.features.check_feature()`](features.html#PIL.features.check_feature "PIL.features.check_feature") with `feature="raqm"`. PIL.ImageFont.MAX_STRING_LENGTH¶ Set to 1,000,000, to protect against potential DOS attacks. Pillow will raise a [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "\(in Python v3.14\)") if the number of characters is over this limit. The check can be disabled by setting `ImageFont.MAX_STRING_LENGTH = None`. ## Dictionaries¶ class PIL.ImageFont.Axis[[source]](../_modules/PIL/ImageFont.html#Axis)¶ Bases: [`TypedDict`](https://docs.python.org/3/library/typing.html#typing.TypedDict "\(in Python v3.14\)") default: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ maximum: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ minimum: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ name: [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ [ Next `ImageGrab` module ](ImageGrab.html) [ Previous `ImageFilter` module ](ImageFilter.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImageFont` module * Example * Functions * `load()` * `load_path()` * `truetype()` * `load_default()` * `load_default_imagefont()` * Methods * `ImageFont` * `ImageFont.getbbox()` * `ImageFont.getlength()` * `ImageFont.getmask()` * `FreeTypeFont` * `FreeTypeFont.font_variant()` * `FreeTypeFont.get_variation_axes()` * `FreeTypeFont.get_variation_names()` * `FreeTypeFont.getbbox()` * `FreeTypeFont.getlength()` * `FreeTypeFont.getmask()` * `FreeTypeFont.getmask2()` * `FreeTypeFont.getmetrics()` * `FreeTypeFont.getname()` * `FreeTypeFont.set_variation_by_axes()` * `FreeTypeFont.set_variation_by_name()` * `TransposedFont` * `TransposedFont.getbbox()` * `TransposedFont.getlength()` * `TransposedFont.getmask()` * Constants * `Layout` * `Layout.BASIC` * `Layout.RAQM` * `MAX_STRING_LENGTH` * Dictionaries * `Axis` * `Axis.default` * `Axis.maximum` * `Axis.minimum` * `Axis.name` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImageGrab.html # Path: reference/ImageGrab.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * `ImageGrab` module * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImageGrab.rst.txt "View this page") # `ImageGrab` module¶ The `ImageGrab` module can be used to copy the contents of the screen or the clipboard to a PIL image memory. Added in version 1.1.3. PIL.ImageGrab.grab(_bbox =None_, _include_layered_windows =False_, _all_screens =False_, _xdisplay =None_, _window =None_)[[source]](../_modules/PIL/ImageGrab.html#grab)¶ Take a snapshot of the screen. The pixels inside the bounding box are returned as an “RGBA” on macOS, or an “RGB” image otherwise. If the bounding box is omitted, the entire screen is copied, and on macOS, it will be at 2x if on a Retina screen. On Linux, if `xdisplay` is `None` and the default X11 display does not return a snapshot of the screen, `gnome-screenshot`, `grim` or `spectacle` will be used as a fallback if they are installed. To disable this behaviour, pass `xdisplay=""` instead. Added in version 1.1.3: Windows support Added in version 3.0.0: macOS support Added in version 7.1.0: Linux support Parameters: * **bbox** – What region to copy. Default is the entire screen. On macOS, this is not increased to 2x for Retina screens, so the full width of a Retina screen would be 1440, not 2880. On Windows, the top-left point may be negative if `all_screens=True` is used. * **include_layered_windows** – Includes layered windows. Windows OS only. Added in version 6.1.0. * **all_screens** – Capture all monitors. Windows OS only. Added in version 6.2.0. * **xdisplay** – X11 Display address. Pass [`None`](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") to grab the default system screen. Pass `""` to grab the default X11 screen on Windows or macOS. You can check X11 support using [`PIL.features.check_feature()`](features.html#PIL.features.check_feature "PIL.features.check_feature") with `feature="xcb"`. Added in version 7.1.0. * **window** – Capture a single window. On Windows, this is a HWND. On macOS, this is a CGWindowID. Added in version 11.2.1: Windows support Added in version 12.1.0: macOS support Returns: An image PIL.ImageGrab.grabclipboard()[[source]](../_modules/PIL/ImageGrab.html#grabclipboard)¶ Take a snapshot of the clipboard image, if any. On Linux, `wl-paste` or `xclip` is required. Added in version 1.1.4: Windows support Added in version 3.3.0: macOS support Added in version 9.4.0: Linux support Returns: On Windows, an image, a list of filenames, or None if the clipboard does not contain image data or filenames. Note that if a list is returned, the filenames may not represent image files. On Mac, an image, or None if the clipboard does not contain image data. On Linux, an image. [ Next `ImageMath` module ](ImageMath.html) [ Previous `ImageFont` module ](ImageFont.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImageGrab` module * `grab()` * `grabclipboard()` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImageMath.html # Path: reference/ImageMath.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * `ImageMath` module * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImageMath.rst.txt "View this page") # `ImageMath` module¶ The `ImageMath` module can be used to evaluate “image expressions”, that can take a number of images and generate a result. `ImageMath` only supports single-layer images. To process multi-band images, use the [`split()`](Image.html#PIL.Image.Image.split "PIL.Image.Image.split") method or [`merge()`](Image.html#PIL.Image.merge "PIL.Image.merge") function. ## Example: Using the `ImageMath` module¶ from PIL import Image, ImageMath with Image.open("image1.jpg") as im1: with Image.open("image2.jpg") as im2: out = ImageMath.lambda_eval( lambda args: args["convert"](args["min"](args["a"], args["b"]), 'L'), a=im1, b=im2 ) out = ImageMath.unsafe_eval( "convert(min(a, b), 'L')", a=im1, b=im2 ) PIL.ImageMath.lambda_eval(_expression_ , _options_ , _** kw_)[[source]](../_modules/PIL/ImageMath.html#lambda_eval)¶ Returns the result of an image function. Parameters: * **expression** – A function that receives a dictionary. * **options** – Values to add to the function’s dictionary. Note that the names must be valid Python identifiers. Deprecated. You can instead use one or more keyword arguments, as shown in the above example. * ****kw** – Values to add to the function’s dictionary, mapping image names to Image instances. Returns: An image, an integer value, a floating point value, or a pixel tuple, depending on the expression. PIL.ImageMath.unsafe_eval(_expression_ , _options_ , _** kw_)[[source]](../_modules/PIL/ImageMath.html#unsafe_eval)¶ Evaluates an image expression. Danger This uses Python’s `eval()` function to process the expression string, and carries the security risks of doing so. It is not recommended to process expressions without considering this. `lambda_eval()` is a more secure alternative. `ImageMath` only supports single-layer images. To process multi-band images, use the [`split()`](Image.html#PIL.Image.Image.split "PIL.Image.Image.split") method or [`merge()`](Image.html#PIL.Image.merge "PIL.Image.merge") function. Parameters: * **expression** – A string which uses the standard Python expression syntax. In addition to the standard operators, you can also use the functions described below. * **options** – Values to add to the evaluation context. Note that the names must be valid Python identifiers. Deprecated. You can instead use one or more keyword arguments, as shown in the above example. * ****kw** – Values to add to the evaluation context, mapping image names to Image instances. Returns: An image, an integer value, a floating point value, or a pixel tuple, depending on the expression. ## Expression syntax¶ * `lambda_eval()` expressions are functions that receive a dictionary containing images and operators. * `unsafe_eval()` expressions are standard Python expressions, but they’re evaluated in a non-standard environment. Danger `unsafe_eval()` uses Python’s `eval()` function to process the expression string, and carries the security risks of doing so. It is not recommended to process expressions without considering this. `lambda_eval()` is a more secure alternative. ### Standard operators¶ You can use standard arithmetical operators for addition (+), subtraction (-), multiplication (*), and division (/). The module also supports unary minus (-), modulo (%), and power (**) operators. Note that all operations are done with 32-bit integers or 32-bit floating point values, as necessary. For example, if you add two 8-bit images, the result will be a 32-bit integer image. If you add a floating point constant to an 8-bit image, the result will be a 32-bit floating point image. You can force conversion using the `convert()`, `float()`, and `int()` functions described below. ### Bitwise operators¶ The module also provides operations that operate on individual bits. This includes and (&), or (|), and exclusive or (^). You can also invert (~) all pixel bits. Note that the operands are converted to 32-bit signed integers before the bitwise operation is applied. This means that you’ll get negative values if you invert an ordinary grayscale image. You can use the and (&) operator to mask off unwanted bits. Bitwise operators don’t work on floating point images. ### Logical operators¶ Logical operators like `and`, `or`, and `not` work on entire images, rather than individual pixels. An empty image (all pixels zero) is treated as false. All other images are treated as true. Note that `and` and `or` return the last evaluated operand, while not always returns a boolean value. ### Built-in functions¶ These functions are applied to each individual pixel. abs(_image_) Absolute value. convert(_image_ , _mode_) Convert image to the given mode. The mode must be given as a string constant. float(_image_) Convert image to 32-bit floating point. This is equivalent to convert(image, “F”). int(_image_) Convert image to 32-bit integer. This is equivalent to convert(image, “I”). Note that 1-bit and 8-bit images are automatically converted to 32-bit integers if necessary to get a correct result. max(_image1_ , _image2_) Maximum value. min(_image1_ , _image2_) Minimum value. [ Next `ImageMorph` module ](ImageMorph.html) [ Previous `ImageGrab` module ](ImageGrab.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImageMath` module * Example: Using the `ImageMath` module * `lambda_eval()` * `unsafe_eval()` * Expression syntax * Standard operators * Bitwise operators * Logical operators * Built-in functions --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImageMorph.html # Path: reference/ImageMorph.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * `ImageMorph` module * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImageMorph.rst.txt "View this page") # `ImageMorph` module¶ The `ImageMorph` module allows [morphology](https://en.wikipedia.org/wiki/Mathematical_morphology) operators (“MorphOp”) to be applied to L mode images: from PIL import Image, ImageMorph img = Image.open("Tests/images/hopper.bw") mop = ImageMorph.MorphOp(op_name="erosion4") count, imgOut = mop.apply(img) imgOut.show() In addition to applying operators, you can also analyse images. You can inspect an image in isolation to determine which pixels are non-empty: print(mop.get_on_pixels(img)) # [(0, 0), (1, 0), (2, 0), ...] Or you can retrieve a list of pixels that match the operator. This is the number of pixels that will be non-empty after the operator is applied: coords = mop.match(img) print(coords) # [(17, 1), (18, 1), (34, 1), ...] print(len(coords)) # 550 imgOut = mop.apply(img)[1] print(len(mop.get_on_pixels(imgOut))) # 550 If you would like more customized operators, you can pass patterns to the MorphOp class: mop = ImageMorph.MorphOp(patterns=["1:(... ... ...)->0", "4:(00. 01. ...)->1"]) Or you can pass lookup table (“LUT”) data directly. This LUT data can be constructed with the `LutBuilder`: builder = ImageMorph.LutBuilder() mop = ImageMorph.MorphOp(lut=builder.build_lut()) class PIL.ImageMorph.LutBuilder(_patterns : [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _op_name : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/ImageMorph.html#LutBuilder)¶ Bases: [`object`](https://docs.python.org/3/library/functions.html#object "\(in Python v3.14\)") A class for building a MorphLut from a descriptive language The input patterns is a list of a strings sequences like these: 4:(... .1. 111)->1 (whitespaces including linebreaks are ignored). The option 4 describes a series of symmetry operations (in this case a 4-rotation), the pattern is described by: * . or X - Ignore * 1 - Pixel is on * 0 - Pixel is off The result of the operation is described after “->” string. The default is to return the current pixel value, which is returned if no other match is found. Operations: * 4 - 4 way rotation * N - Negate * 1 - Dummy op for no other operation (an op must always be given) * M - Mirroring Example: lb = LutBuilder(patterns = ["4:(... .1. 111)->1"]) lut = lb.build_lut() add_patterns(_patterns : [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")]_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageMorph.html#LutBuilder.add_patterns)¶ Append to list of patterns. Parameters: **patterns** – Additional patterns. build_default_lut() -> [bytearray](https://docs.python.org/3/library/stdtypes.html#bytearray "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageMorph.html#LutBuilder.build_default_lut)¶ Set the current LUT, and return it. This is the default LUT that patterns will be applied against when building. build_lut() -> [bytearray](https://docs.python.org/3/library/stdtypes.html#bytearray "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageMorph.html#LutBuilder.build_lut)¶ Compile all patterns into a morphology LUT, and return it. This is the data to be passed into MorphOp. get_lut() -> [bytearray](https://docs.python.org/3/library/stdtypes.html#bytearray "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageMorph.html#LutBuilder.get_lut)¶ Returns the current LUT class PIL.ImageMorph.MorphOp(_lut : [bytearray](https://docs.python.org/3/library/stdtypes.html#bytearray "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _op_name : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _patterns : [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/ImageMorph.html#MorphOp)¶ Bases: [`object`](https://docs.python.org/3/library/functions.html#object "\(in Python v3.14\)") A class for binary morphological operators apply(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [Image](Image.html#PIL.Image.Image "PIL.Image.Image")][[source]](../_modules/PIL/ImageMorph.html#MorphOp.apply)¶ Run a single morphological operation on an image. Returns a tuple of the number of changed pixels and the morphed image. Raises: * [**Exception**](https://docs.python.org/3/library/exceptions.html#Exception "\(in Python v3.14\)") – If the current operator is None. * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "\(in Python v3.14\)") – If the image is not L mode. get_on_pixels(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]][[source]](../_modules/PIL/ImageMorph.html#MorphOp.get_on_pixels)¶ Get a list of all turned on pixels in a grayscale image Returns a list of tuples of (x,y) coordinates of all non-empty pixels. See [Coordinate system](../handbook/concepts.html#coordinate-system). Parameters: **image** – An L-mode image. Raises: [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "\(in Python v3.14\)") – If the image is not L mode. load_lut(_filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageMorph.html#MorphOp.load_lut)¶ Load an operator from an mrl file Parameters: **filename** – The file to read from. Raises: [**Exception**](https://docs.python.org/3/library/exceptions.html#Exception "\(in Python v3.14\)") – If the length of the file data is not 512. match(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]][[source]](../_modules/PIL/ImageMorph.html#MorphOp.match)¶ Get a list of coordinates matching the morphological operation on an image. Returns a list of tuples of (x,y) coordinates of all matching pixels. See [Coordinate system](../handbook/concepts.html#coordinate-system). Parameters: **image** – An L-mode image. Raises: * [**Exception**](https://docs.python.org/3/library/exceptions.html#Exception "\(in Python v3.14\)") – If the current operator is None. * [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "\(in Python v3.14\)") – If the image is not L mode. save_lut(_filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageMorph.html#MorphOp.save_lut)¶ Save an operator to an mrl file. Parameters: **filename** – The destination file. Raises: [**Exception**](https://docs.python.org/3/library/exceptions.html#Exception "\(in Python v3.14\)") – If the current operator is None. set_lut(_lut : [bytearray](https://docs.python.org/3/library/stdtypes.html#bytearray "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageMorph.html#MorphOp.set_lut)¶ Set the LUT from an external source Parameters: **lut** – A new LUT. [ Next `ImageOps` module ](ImageOps.html) [ Previous `ImageMath` module ](ImageMath.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImageMorph` module * `LutBuilder` * `LutBuilder.add_patterns()` * `LutBuilder.build_default_lut()` * `LutBuilder.build_lut()` * `LutBuilder.get_lut()` * `MorphOp` * `MorphOp.apply()` * `MorphOp.get_on_pixels()` * `MorphOp.load_lut()` * `MorphOp.match()` * `MorphOp.save_lut()` * `MorphOp.set_lut()` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImageOps.html # Path: reference/ImageOps.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * `ImageOps` module * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImageOps.rst.txt "View this page") # `ImageOps` module¶ The `ImageOps` module contains a number of ‘ready-made’ image processing operations. This module is somewhat experimental, and most operators only work on L and RGB images. Added in version 1.1.3. PIL.ImageOps.autocontrast(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _cutoff : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] = 0_, _ignore : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _mask : [Image](Image.html#PIL.Image.Image "PIL.Image.Image") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _preserve_tone : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = False_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageOps.html#autocontrast)¶ Maximize (normalize) image contrast. This function calculates a histogram of the input image (or mask region), removes `cutoff` percent of the lightest and darkest pixels from the histogram, and remaps the image so that the darkest pixel becomes black (0), and the lightest becomes white (255). Parameters: * **image** – The image to process. * **cutoff** – The percent to cut off from the histogram on the low and high ends. Either a tuple of (low, high), or a single number for both. * **ignore** – The background pixel value (use None for no background). * **mask** – Histogram used in contrast operation is computed using pixels within the mask. If no mask is given the entire image is used for histogram computation. * **preserve_tone** – Preserve image tone in Photoshop-like style autocontrast. Added in version 8.2.0. Returns: An image. PIL.ImageOps.colorize(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _black : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), ...]_, _white : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), ...]_, _mid : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), ...] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _blackpoint : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 0_, _whitepoint : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 255_, _midpoint : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 127_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageOps.html#colorize)¶ Colorize grayscale image. This function calculates a color wedge which maps all black pixels in the source image to the first color and all white pixels to the second color. If `mid` is specified, it uses three-color mapping. The `black` and `white` arguments should be RGB tuples or color names; optionally you can use three-color mapping by also specifying `mid`. Mapping positions for any of the colors can be specified (e.g. `blackpoint`), where these parameters are the integer value corresponding to where the corresponding color should be mapped. These parameters must have logical order, such that `blackpoint <= midpoint <= whitepoint` (if `mid` is specified). Parameters: * **image** – The image to colorize. * **black** – The color to use for black input pixels. * **white** – The color to use for white input pixels. * **mid** – The color to use for midtone input pixels. * **blackpoint** – an int value [0, 255] for the black mapping. * **whitepoint** – an int value [0, 255] for the white mapping. * **midpoint** – an int value [0, 255] for the midtone mapping. Returns: An image. PIL.ImageOps.crop(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _border : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 0_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageOps.html#crop)¶ Remove border from image. The same amount of pixels are removed from all four sides. This function works on all image modes. See also [`crop()`](Image.html#PIL.Image.Image.crop "PIL.Image.Image.crop") Parameters: * **image** – The image to crop. * **border** – The number of pixels to remove. Returns: An image. PIL.ImageOps.scale(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _factor : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")_, _resample : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = Resampling.BICUBIC_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageOps.html#scale)¶ Returns a rescaled image by a specific factor given in parameter. A factor greater than 1 expands the image, between 0 and 1 contracts the image. Parameters: * **image** – The image to rescale. * **factor** – The expansion factor, as a float. * **resample** – Resampling method to use. Default is [`BICUBIC`](Image.html#PIL.Image.Resampling.BICUBIC "PIL.Image.Resampling.BICUBIC"). See [Filters](../handbook/concepts.html#concept-filters). Returns: An [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") object. class PIL.ImageOps.SupportsGetMesh(_* args_, _** kwargs_)[[source]](../_modules/PIL/ImageOps.html#SupportsGetMesh)¶ Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol "\(in Python v3.14\)") An object that supports the `getmesh` method, taking an image as an argument, and returning a list of tuples. Each tuple contains two tuples, the source box as a tuple of 4 integers, and a tuple of 8 integers for the final quadrilateral, in order of top left, bottom left, bottom right, top right. PIL.ImageOps.deform(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _deformer : SupportsGetMesh_, _resample : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = Resampling.BILINEAR_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageOps.html#deform)¶ Deform the image. Parameters: * **image** – The image to deform. * **deformer** – A deformer object. Any object that implements a `getmesh` method can be used. * **resample** – An optional resampling filter. Same values possible as in the PIL.Image.transform function. Returns: An image. PIL.ImageOps.equalize(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _mask : [Image](Image.html#PIL.Image.Image "PIL.Image.Image") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageOps.html#equalize)¶ Equalize the image histogram. This function applies a non-linear mapping to the input image, in order to create a uniform distribution of grayscale values in the output image. Parameters: * **image** – The image to equalize. * **mask** – An optional mask. If given, only the pixels selected by the mask are included in the analysis. Returns: An image. PIL.ImageOps.expand(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _border : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), ...] = 0_, _fill : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), ...] = 0_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageOps.html#expand)¶ Add border to the image Parameters: * **image** – The image to expand. * **border** – Border width, in pixels. * **fill** – Pixel fill value (a color value). Default is 0 (black). Returns: An image. PIL.ImageOps.flip(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageOps.html#flip)¶ Flip the image vertically (top to bottom). Parameters: **image** – The image to flip. Returns: An image. PIL.ImageOps.grayscale(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageOps.html#grayscale)¶ Convert the image to grayscale. Parameters: **image** – The image to convert. Returns: An image. PIL.ImageOps.invert(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageOps.html#invert)¶ Invert (negate) the image. Parameters: **image** – The image to invert. Returns: An image. PIL.ImageOps.mirror(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageOps.html#mirror)¶ Flip image horizontally (left to right). Parameters: **image** – The image to mirror. Returns: An image. PIL.ImageOps.posterize(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _bits : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageOps.html#posterize)¶ Reduce the number of bits for each color channel. Parameters: * **image** – The image to posterize. * **bits** – The number of bits to keep for each channel (1-8). Returns: An image. PIL.ImageOps.solarize(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _threshold : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 128_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageOps.html#solarize)¶ Invert all pixel values above a threshold. Parameters: * **image** – The image to solarize. * **threshold** – All pixels above this grayscale level are inverted. Returns: An image. PIL.ImageOps.exif_transpose(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _*_ , _in_place : [Literal](https://docs.python.org/3/library/typing.html#typing.Literal "\(in Python v3.14\)")[True]_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageOps.html#exif_transpose)¶ PIL.ImageOps.exif_transpose(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _*_ , _in_place : [Literal](https://docs.python.org/3/library/typing.html#typing.Literal "\(in Python v3.14\)")[False] = False_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image") If an image has an EXIF Orientation tag, other than 1, transpose the image accordingly, and remove the orientation data. Parameters: * **image** – The image to transpose. * **in_place** – Boolean. Keyword-only argument. If `True`, the original image is modified in-place, and `None` is returned. If `False` (default), a new [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") object is returned with the transposition applied. If there is no transposition, a copy of the image will be returned. ## Resize relative to a given size¶ from PIL import Image, ImageOps size = (100, 150) with Image.open("Tests/images/hopper.webp") as im: ImageOps.contain(im, size).save("imageops_contain.webp") ImageOps.cover(im, size).save("imageops_cover.webp") ImageOps.fit(im, size).save("imageops_fit.webp") ImageOps.pad(im, size, color="#f00").save("imageops_pad.webp") # thumbnail() can also be used, # but will modify the image object in place im.thumbnail(size) im.save("image_thumbnail.webp") | [`thumbnail()`](Image.html#PIL.Image.Image.thumbnail "PIL.Image.Image.thumbnail") | `contain()` | `cover()` | `fit()` | `pad()` ---|---|---|---|---|--- Given size | `(100, 150)` | `(100, 150)` | `(100, 150)` | `(100, 150)` | `(100, 150)` Resulting image | ![../_images/image_thumbnail.webp](../_images/image_thumbnail.webp) | ![../_images/imageops_contain.webp](../_images/imageops_contain.webp) | ![../_images/imageops_cover.webp](../_images/imageops_cover.webp) | ![../_images/imageops_fit.webp](../_images/imageops_fit.webp) | ![../_images/imageops_pad.webp](../_images/imageops_pad.webp) Resulting size | `100×100` | `100×100` | `150×150` | `100×150` | `100×150` PIL.ImageOps.contain(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _method : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = Resampling.BICUBIC_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageOps.html#contain)¶ Returns a resized version of the image, set to the maximum width and height within the requested size, while maintaining the original aspect ratio. Parameters: * **image** – The image to resize. * **size** – The requested output size in pixels, given as a (width, height) tuple. * **method** – Resampling method to use. Default is [`BICUBIC`](Image.html#PIL.Image.Resampling.BICUBIC "PIL.Image.Resampling.BICUBIC"). See [Filters](../handbook/concepts.html#concept-filters). Returns: An image. PIL.ImageOps.cover(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _method : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = Resampling.BICUBIC_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageOps.html#cover)¶ Returns a resized version of the image, so that the requested size is covered, while maintaining the original aspect ratio. Parameters: * **image** – The image to resize. * **size** – The requested output size in pixels, given as a (width, height) tuple. * **method** – Resampling method to use. Default is [`BICUBIC`](Image.html#PIL.Image.Resampling.BICUBIC "PIL.Image.Resampling.BICUBIC"). See [Filters](../handbook/concepts.html#concept-filters). Returns: An image. PIL.ImageOps.fit(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _method : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = Resampling.BICUBIC_, _bleed : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") = 0.0_, _centering : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] = (0.5, 0.5)_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageOps.html#fit)¶ Returns a resized and cropped version of the image, cropped to the requested aspect ratio and size. This function was contributed by Kevin Cazabon. Parameters: * **image** – The image to resize and crop. * **size** – The requested output size in pixels, given as a (width, height) tuple. * **method** – Resampling method to use. Default is [`BICUBIC`](Image.html#PIL.Image.Resampling.BICUBIC "PIL.Image.Resampling.BICUBIC"). See [Filters](../handbook/concepts.html#concept-filters). * **bleed** – Remove a border around the outside of the image from all four edges. The value is a decimal percentage (use 0.01 for one percent). The default value is 0 (no border). Cannot be greater than or equal to 0.5. * **centering** – Control the cropping position. Use (0.5, 0.5) for center cropping (e.g. if cropping the width, take 50% off of the left side, and therefore 50% off the right side). (0.0, 0.0) will crop from the top left corner (i.e. if cropping the width, take all of the crop off of the right side, and if cropping the height, take all of it off the bottom). (1.0, 0.0) will crop from the bottom left corner, etc. (i.e. if cropping the width, take all of the crop off the left side, and if cropping the height take none from the top, and therefore all off the bottom). Returns: An image. PIL.ImageOps.pad(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _method : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = Resampling.BICUBIC_, _color : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), ...] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _centering : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] = (0.5, 0.5)_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageOps.html#pad)¶ Returns a resized and padded version of the image, expanded to fill the requested aspect ratio and size. Parameters: * **image** – The image to resize and crop. * **size** – The requested output size in pixels, given as a (width, height) tuple. * **method** – Resampling method to use. Default is [`BICUBIC`](Image.html#PIL.Image.Resampling.BICUBIC "PIL.Image.Resampling.BICUBIC"). See [Filters](../handbook/concepts.html#concept-filters). * **color** – The background color of the padded image. * **centering** – Control the position of the original image within the padded version. > (0.5, 0.5) will keep the image centered (0, 0) will keep the image aligned > to the top left (1, 1) will keep the image aligned to the bottom right Returns: An image. [ Next `ImagePalette` module ](ImagePalette.html) [ Previous `ImageMorph` module ](ImageMorph.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImageOps` module * `autocontrast()` * `colorize()` * `crop()` * `scale()` * `SupportsGetMesh` * `deform()` * `equalize()` * `expand()` * `flip()` * `grayscale()` * `invert()` * `mirror()` * `posterize()` * `solarize()` * `exif_transpose()` * Resize relative to a given size * `contain()` * `cover()` * `fit()` * `pad()` *[*]: Keyword-only parameters separator (PEP 3102) --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImagePalette.html # Path: reference/ImagePalette.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * `ImagePalette` module * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImagePalette.rst.txt "View this page") # `ImagePalette` module¶ The `ImagePalette` module contains a class of the same name to represent the color palette of palette mapped images. Note The `ImagePalette` class has several methods, but they are all marked as “experimental.” Read that as you will. The `[source]` link is there for a reason. class PIL.ImagePalette.ImagePalette(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") = 'RGB'_, _palette : [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [bytearray](https://docs.python.org/3/library/stdtypes.html#bytearray "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/ImagePalette.html#ImagePalette)¶ Color palette for palette mapped images Parameters: * **mode** – The mode to use for the palette. See: [Modes](../handbook/concepts.html#concept-modes). Defaults to “RGB” * **palette** – An optional palette. If given, it must be a bytearray, an array or a list of ints between 0-255. The list must consist of all channels for one color followed by the next color (e.g. RGBRGBRGB). Defaults to an empty palette. getcolor(_color : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), ...]_, _image : [Image.Image](Image.html#PIL.Image.Image "PIL.Image.Image") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/ImagePalette.html#ImagePalette.getcolor)¶ Given an rgb tuple, allocate palette entry. Warning This method is experimental. getdata() -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [bytearray](https://docs.python.org/3/library/stdtypes.html#bytearray "\(in Python v3.14\)")][[source]](../_modules/PIL/ImagePalette.html#ImagePalette.getdata)¶ Get palette contents in format suitable for the low-level `im.putpalette` primitive. Warning This method is experimental. save(_fp : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")]_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImagePalette.html#ImagePalette.save)¶ Save palette to text file. Warning This method is experimental. tobytes() -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/ImagePalette.html#ImagePalette.tobytes)¶ Convert palette to bytes. Warning This method is experimental. tostring() -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")¶ Convert palette to bytes. Warning This method is experimental. [ Next `ImagePath` module ](ImagePath.html) [ Previous `ImageOps` module ](ImageOps.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImagePalette` module * `ImagePalette` * `ImagePalette.getcolor()` * `ImagePalette.getdata()` * `ImagePalette.save()` * `ImagePalette.tobytes()` * `ImagePalette.tostring()` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImagePath.html # Path: reference/ImagePath.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * `ImagePath` module * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImagePath.rst.txt "View this page") # `ImagePath` module¶ The `ImagePath` module is used to store and manipulate 2-dimensional vector data. Path objects can be passed to the methods on the [`ImageDraw`](ImageDraw.html#module-PIL.ImageDraw "PIL.ImageDraw") module. class PIL.ImagePath.Path¶ A path object. The coordinate list can be any sequence object containing either 2-tuples [(x, y), …] or numeric values [x, y, …]. You can also create a path object from another path object. In 1.1.6 and later, you can also pass in any object that implements Python’s buffer API. The buffer should provide read access, and contain C floats in machine byte order. The path object implements most parts of the Python sequence interface, and behaves like a list of (x, y) pairs. You can use len(), item access, and slicing as usual. However, this does not support slice assignment, or item and slice deletion. Parameters: **xy** – A sequence. The sequence can contain 2-tuples [(x, y), …] or a flat list of numbers [x, y, …]. PIL.ImagePath.Path.compact(_distance =2_)¶ Compacts the path, by removing points that are close to each other. This method modifies the path in place, and returns the number of points left in the path. `distance` is measured as [Manhattan distance](https://en.wikipedia.org/wiki/Manhattan_distance) and defaults to two pixels. PIL.ImagePath.Path.getbbox()¶ Gets the bounding box of the path. Returns: `(x0, y0, x1, y1)` PIL.ImagePath.Path.map(_function_)¶ Maps the path through a function. PIL.ImagePath.Path.tolist(_flat =False_)¶ Converts the path to a Python list [(x, y), …]. Parameters: **flat** – By default, this function returns a list of 2-tuples [(x, y), …]. If this argument is `True`, it returns a flat list [x, y, …] instead. Returns: A list of coordinates. See `flat`. PIL.ImagePath.Path.transform(_matrix_)¶ Transforms the path in place, using an affine transform. The matrix is a 6-tuple (a, b, c, d, e, f), and each point is mapped as follows: xOut = xIn * a + yIn * b + c yOut = xIn * d + yIn * e + f [ Next `ImageQt` module ](ImageQt.html) [ Previous `ImagePalette` module ](ImagePalette.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImagePath` module * `PIL.ImagePath.Path` * `PIL.ImagePath.Path.compact()` * `PIL.ImagePath.Path.getbbox()` * `PIL.ImagePath.Path.map()` * `PIL.ImagePath.Path.tolist()` * `PIL.ImagePath.Path.transform()` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImageSequence.html # Path: reference/ImageSequence.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * `ImageSequence` module * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImageSequence.rst.txt "View this page") # `ImageSequence` module¶ The `ImageSequence` module contains a wrapper class that lets you iterate over the frames of an image sequence. ## Extracting frames from an animation¶ from PIL import Image, ImageSequence with Image.open("animation.fli") as im: index = 1 for frame in ImageSequence.Iterator(im): frame.save(f"frame{index}.png") index += 1 ## The `Iterator` class¶ class PIL.ImageSequence.Iterator(_im : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_)[[source]](../_modules/PIL/ImageSequence.html#Iterator)¶ This class implements an iterator object that can be used to loop over an image sequence. You can use the `[]` operator to access elements by index. This operator will raise an [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "\(in Python v3.14\)") if you try to access a nonexistent frame. Parameters: **im** – An image object. ## Functions¶ PIL.ImageSequence.all_frames(_im : [Image.Image](Image.html#PIL.Image.Image "PIL.Image.Image") | [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[Image.Image](Image.html#PIL.Image.Image "PIL.Image.Image")]_, _func : Callable[[[Image.Image](Image.html#PIL.Image.Image "PIL.Image.Image")], [Image.Image](Image.html#PIL.Image.Image "PIL.Image.Image")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[Image.Image](Image.html#PIL.Image.Image "PIL.Image.Image")][[source]](../_modules/PIL/ImageSequence.html#all_frames)¶ Applies a given function to all frames in an image or a list of images. The frames are returned as a list of separate images. Parameters: * **im** – An image, or a list of images. * **func** – The function to apply to all of the image frames. Returns: A list of images. [ Next `ImageShow` module ](ImageShow.html) [ Previous `ImageQt` module ](ImageQt.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImageSequence` module * Extracting frames from an animation * The `Iterator` class * `Iterator` * Functions * `all_frames()` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImageStat.html # Path: reference/ImageStat.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * `ImageStat` module * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImageStat.rst.txt "View this page") # `ImageStat` module¶ The `ImageStat` module calculates global statistics for an image, or for a region of an image. class PIL.ImageStat.Stat(_image_or_list : [Image](Image.html#PIL.Image.Image "PIL.Image.Image") | [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _mask : [Image](Image.html#PIL.Image.Image "PIL.Image.Image") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/ImageStat.html#Stat)¶ __init__(_image_or_list : [Image](Image.html#PIL.Image.Image "PIL.Image.Image") | [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _mask : [Image](Image.html#PIL.Image.Image "PIL.Image.Image") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageStat.html#Stat.__init__)¶ Calculate statistics for the given image. If a mask is included, only the regions covered by that mask are included in the statistics. You can also pass in a previously calculated histogram. Parameters: * **image** – A PIL image, or a precalculated histogram. Note For a PIL image, calculations rely on the [`histogram()`](Image.html#PIL.Image.Image.histogram "PIL.Image.Image.histogram") method. The pixel counts are grouped into 256 bins, even if the image has more than 8 bits per channel. So `I` and `F` mode images have a maximum `mean`, `median` and `rms` of 255, and cannot have an `extrema` maximum of more than 255. * **mask** – An optional mask. property count: [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/ImageStat.html#Stat.count)¶ Total number of pixels for each band in the image. property extrema: [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]][[source]](../_modules/PIL/ImageStat.html#Stat.extrema)¶ Min/max values for each band in the image. Note This relies on the [`histogram()`](Image.html#PIL.Image.Image.histogram "PIL.Image.Image.histogram") method, and simply returns the low and high bins used. This is correct for images with 8 bits per channel, but fails for other modes such as `I` or `F`. Instead, use [`getextrema()`](Image.html#PIL.Image.Image.getextrema "PIL.Image.Image.getextrema") to return per-band extrema for the image. This is more correct and efficient because, for non-8-bit modes, the histogram method uses [`getextrema()`](Image.html#PIL.Image.Image.getextrema "PIL.Image.Image.getextrema") to determine the bins used. property mean: [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")][[source]](../_modules/PIL/ImageStat.html#Stat.mean)¶ Average (arithmetic mean) pixel level for each band in the image. property median: [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/ImageStat.html#Stat.median)¶ Median pixel level for each band in the image. property rms: [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")][[source]](../_modules/PIL/ImageStat.html#Stat.rms)¶ RMS (root-mean-square) for each band in the image. property stddev: [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")][[source]](../_modules/PIL/ImageStat.html#Stat.stddev)¶ Standard deviation for each band in the image. property sum: [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")][[source]](../_modules/PIL/ImageStat.html#Stat.sum)¶ Sum of all pixels for each band in the image. property sum2: [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")][[source]](../_modules/PIL/ImageStat.html#Stat.sum2)¶ Squared sum of all pixels for each band in the image. property var: [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")][[source]](../_modules/PIL/ImageStat.html#Stat.var)¶ Variance for each band in the image. [ Next `ImageText` module ](ImageText.html) [ Previous `ImageShow` module ](ImageShow.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImageStat` module * `Stat` * `Stat.__init__()` * `Stat.count` * `Stat.extrema` * `Stat.mean` * `Stat.median` * `Stat.rms` * `Stat.stddev` * `Stat.sum` * `Stat.sum2` * `Stat.var` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImageTk.html # Path: reference/ImageTk.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * `ImageTk` module * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImageTk.rst.txt "View this page") # `ImageTk` module¶ The `ImageTk` module contains support to create and modify Tkinter BitmapImage and PhotoImage objects from PIL images. For examples, see the demo programs in the Scripts directory. class PIL.ImageTk.BitmapImage(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _** kw: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_)[[source]](../_modules/PIL/ImageTk.html#BitmapImage)¶ A Tkinter-compatible bitmap image. This can be used everywhere Tkinter expects an image object. The given image must have mode “1”. Pixels having value 0 are treated as transparent. Options, if any, are passed on to Tkinter. The most commonly used option is `foreground`, which is used to specify the color for the non- transparent parts. See the Tkinter documentation for information on how to specify colours. Parameters: **image** – A PIL image. height() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageTk.html#BitmapImage.height)¶ Get the height of the image. Returns: The height, in pixels. width() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageTk.html#BitmapImage.width)¶ Get the width of the image. Returns: The width, in pixels. class PIL.ImageTk.PhotoImage(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image") | [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _** kw: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_)[[source]](../_modules/PIL/ImageTk.html#PhotoImage)¶ A Tkinter-compatible photo image. This can be used everywhere Tkinter expects an image object. If the image is an RGBA image, pixels having alpha 0 are treated as transparent. The constructor takes either a PIL image, or a mode and a size. Alternatively, you can use the `file` or `data` options to initialize the photo image object. Parameters: * **image** – Either a PIL image, or a mode string. If a mode string is used, a size must also be given. * **size** – If the first argument is a mode string, this defines the size of the image. * **file** – A filename to load the image from (using `Image.open(file)`). * **data** – An 8-bit string containing image data (as loaded from an image file). height() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageTk.html#PhotoImage.height)¶ Get the height of the image. Returns: The height, in pixels. paste(_im : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageTk.html#PhotoImage.paste)¶ Paste a PIL image into the photo image. Note that this can be very slow if the photo image is displayed. Parameters: **im** – A PIL image. The size must match the target region. If the mode does not match, the image is converted to the mode of the bitmap image. width() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageTk.html#PhotoImage.width)¶ Get the width of the image. Returns: The width, in pixels. [ Next `ImageTransform` module ](ImageTransform.html) [ Previous `ImageText` module ](ImageText.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImageTk` module * `BitmapImage` * `BitmapImage.height()` * `BitmapImage.width()` * `PhotoImage` * `PhotoImage.height()` * `PhotoImage.paste()` * `PhotoImage.width()` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImageTransform.html # Path: reference/ImageTransform.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * `ImageTransform` module * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImageTransform.rst.txt "View this page") # `ImageTransform` module¶ The `ImageTransform` module contains implementations of [`ImageTransformHandler`](Image.html#PIL.Image.ImageTransformHandler "PIL.Image.ImageTransformHandler") for some of the builtin [`Image.Transform`](Image.html#PIL.Image.Transform "PIL.Image.Transform") methods. class PIL.ImageTransform.Transform(_data : [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "\(in Python v3.14\)")[[Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")]_)[[source]](../_modules/PIL/ImageTransform.html#Transform)¶ Bases: [`ImageTransformHandler`](Image.html#PIL.Image.ImageTransformHandler "PIL.Image.ImageTransformHandler") Base class for other transforms defined in `ImageTransform`. getdata() -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[Transform](Image.html#PIL.Image.Transform "PIL.Image.Transform"), [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]][[source]](../_modules/PIL/ImageTransform.html#Transform.getdata)¶ method: [Transform](Image.html#PIL.Image.Transform "PIL.Image.Transform")¶ transform(_size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _** options: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/ImageTransform.html#Transform.transform)¶ Perform the transform. Called from [`Image.transform()`](Image.html#PIL.Image.Image.transform "PIL.Image.Image.transform"). class PIL.ImageTransform.AffineTransform(_data : [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "\(in Python v3.14\)")[[Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")]_)[[source]](../_modules/PIL/ImageTransform.html#AffineTransform)¶ Bases: `Transform` Define an affine image transform. This function takes a 6-tuple (a, b, c, d, e, f) which contain the first two rows from the inverse of an affine transform matrix. For each pixel (x, y) in the output image, the new value is taken from a position (a x + b y + c, d x + e y + f) in the input image, rounded to nearest pixel. This function can be used to scale, translate, rotate, and shear the original image. See [`Image.transform()`](Image.html#PIL.Image.Image.transform "PIL.Image.Image.transform") Parameters: **matrix** – A 6-tuple (a, b, c, d, e, f) containing the first two rows from the inverse of an affine transform matrix. method: [Transform](Image.html#PIL.Image.Transform "PIL.Image.Transform") = 0¶ class PIL.ImageTransform.PerspectiveTransform(_data : [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "\(in Python v3.14\)")[[Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")]_)[[source]](../_modules/PIL/ImageTransform.html#PerspectiveTransform)¶ Bases: `Transform` Define a perspective image transform. This function takes an 8-tuple (a, b, c, d, e, f, g, h). For each pixel (x, y) in the output image, the new value is taken from a position ((a x + b y + c) / (g x + h y + 1), (d x + e y + f) / (g x + h y + 1)) in the input image, rounded to nearest pixel. This function can be used to scale, translate, rotate, and shear the original image. See [`Image.transform()`](Image.html#PIL.Image.Image.transform "PIL.Image.Image.transform") Parameters: **matrix** – An 8-tuple (a, b, c, d, e, f, g, h). method: [Transform](Image.html#PIL.Image.Transform "PIL.Image.Transform") = 2¶ class PIL.ImageTransform.ExtentTransform(_data : [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "\(in Python v3.14\)")[[Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")]_)[[source]](../_modules/PIL/ImageTransform.html#ExtentTransform)¶ Bases: `Transform` Define a transform to extract a subregion from an image. Maps a rectangle (defined by two corners) from the image to a rectangle of the given size. The resulting image will contain data sampled from between the corners, such that (x0, y0) in the input image will end up at (0,0) in the output image, and (x1, y1) at size. This method can be used to crop, stretch, shrink, or mirror an arbitrary rectangle in the current image. It is slightly slower than crop, but about as fast as a corresponding resize operation. See [`Image.transform()`](Image.html#PIL.Image.Image.transform "PIL.Image.Image.transform") Parameters: **bbox** – A 4-tuple (x0, y0, x1, y1) which specifies two points in the input image’s coordinate system. See [Coordinate system](../handbook/concepts.html#coordinate-system). method: [Transform](Image.html#PIL.Image.Transform "PIL.Image.Transform") = 1¶ class PIL.ImageTransform.QuadTransform(_data : [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "\(in Python v3.14\)")[[Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")]_)[[source]](../_modules/PIL/ImageTransform.html#QuadTransform)¶ Bases: `Transform` Define a quad image transform. Maps a quadrilateral (a region defined by four corners) from the image to a rectangle of the given size. See [`Image.transform()`](Image.html#PIL.Image.Image.transform "PIL.Image.Image.transform") Parameters: **xy** – An 8-tuple (x0, y0, x1, y1, x2, y2, x3, y3) which contain the upper left, lower left, lower right, and upper right corner of the source quadrilateral. method: [Transform](Image.html#PIL.Image.Transform "PIL.Image.Transform") = 3¶ class PIL.ImageTransform.MeshTransform(_data : [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "\(in Python v3.14\)")[[Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")]_)[[source]](../_modules/PIL/ImageTransform.html#MeshTransform)¶ Bases: `Transform` Define a mesh image transform. A mesh transform consists of one or more individual quad transforms. See [`Image.transform()`](Image.html#PIL.Image.Image.transform "PIL.Image.Image.transform") Parameters: **data** – A list of (bbox, quad) tuples. method: [Transform](Image.html#PIL.Image.Transform "PIL.Image.Transform") = 4¶ [ Next `ImageWin` module (Windows-only) ](ImageWin.html) [ Previous `ImageTk` module ](ImageTk.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImageTransform` module * `Transform` * `Transform.getdata()` * `Transform.method` * `Transform.transform()` * `AffineTransform` * `AffineTransform.method` * `PerspectiveTransform` * `PerspectiveTransform.method` * `ExtentTransform` * `ExtentTransform.method` * `QuadTransform` * `QuadTransform.method` * `MeshTransform` * `MeshTransform.method` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/ImageWin.html # Path: reference/ImageWin.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * `ImageWin` module (Windows-only) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/ImageWin.rst.txt "View this page") # `ImageWin` module (Windows-only)¶ The `ImageWin` module contains support to create and display images on Windows. ImageWin can be used with PythonWin and other user interface toolkits that provide access to Windows device contexts or window handles. For example, Tkinter makes the window handle available via the winfo_id method: from PIL import ImageWin dib = ImageWin.Dib(...) hwnd = ImageWin.HWND(widget.winfo_id()) dib.draw(hwnd, xy) class PIL.ImageWin.Dib(_image : [Image](Image.html#PIL.Image.Image "PIL.Image.Image") | [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/ImageWin.html#Dib)¶ A Windows bitmap with the given mode and size. The mode can be one of “1”, “L”, “P”, or “RGB”. If the display requires a palette, this constructor creates a suitable palette and associates it with the image. For an “L” image, 128 graylevels are allocated. For an “RGB” image, a 6x6x6 colour cube is used, together with 20 graylevels. To make sure that palettes work properly under Windows, you must call the `palette` method upon certain events from Windows. Parameters: * **image** – Either a PIL image, or a mode string. If a mode string is used, a size must also be given. The mode can be one of “1”, “L”, “P”, or “RGB”. * **size** – If the first argument is a mode string, this defines the size of the image. draw(_handle : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | HDC | HWND_, _dst : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _src : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageWin.html#Dib.draw)¶ Same as expose, but allows you to specify where to draw the image, and what part of it to draw. The destination and source areas are given as 4-tuple rectangles. If the source is omitted, the entire image is copied. If the source and the destination have different sizes, the image is resized as necessary. expose(_handle : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | HDC | HWND_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageWin.html#Dib.expose)¶ Copy the bitmap contents to a device context. Parameters: **handle** – Device context (HDC), cast to a Python integer, or an HDC or HWND instance. In PythonWin, you can use `CDC.GetHandleAttrib()` to get a suitable handle. frombytes(_buffer : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageWin.html#Dib.frombytes)¶ Load display memory contents from byte data. Parameters: **buffer** – A buffer containing display data (usually data returned from `tobytes()`) paste(_im : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _box : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageWin.html#Dib.paste)¶ Paste a PIL image into the bitmap image. Parameters: * **im** – A PIL image. The size must match the target region. If the mode does not match, the image is converted to the mode of the bitmap image. * **box** – A 4-tuple defining the left, upper, right, and lower pixel coordinate. See [Coordinate system](../handbook/concepts.html#coordinate-system). If None is given instead of a tuple, all of the image is assumed. query_palette(_handle : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | HDC | HWND_) -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageWin.html#Dib.query_palette)¶ Installs the palette associated with the image in the given device context. This method should be called upon **QUERYNEWPALETTE** and **PALETTECHANGED** events from Windows. If this method returns a non-zero value, one or more display palette entries were changed, and the image should be redrawn. Parameters: **handle** – Device context (HDC), cast to a Python integer, or an HDC or HWND instance. Returns: The number of entries that were changed (if one or more entries, this indicates that the image should be redrawn). tobytes() -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/ImageWin.html#Dib.tobytes)¶ Copy display memory contents to bytes object. Returns: A bytes object containing display data. class PIL.ImageWin.HDC(_dc : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_)[[source]](../_modules/PIL/ImageWin.html#HDC)¶ Wraps an HDC integer. The resulting object can be passed to the `draw()` and `expose()` methods. class PIL.ImageWin.HWND(_wnd : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_)[[source]](../_modules/PIL/ImageWin.html#HWND)¶ Wraps an HWND integer. The resulting object can be passed to the `draw()` and `expose()` methods, instead of a DC. [ Next `ExifTags` module ](ExifTags.html) [ Previous `ImageTransform` module ](ImageTransform.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `ImageWin` module (Windows-only) * `Dib` * `Dib.draw()` * `Dib.expose()` * `Dib.frombytes()` * `Dib.paste()` * `Dib.query_palette()` * `Dib.tobytes()` * `HDC` * `HWND` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/PSDraw.html # Path: reference/PSDraw.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * `PSDraw` module * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/PSDraw.rst.txt "View this page") # `PSDraw` module¶ The `PSDraw` module provides simple print support for PostScript printers. You can print text, graphics and images through this module. class PIL.PSDraw.PSDraw(_fp : [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/PSDraw.html#PSDraw)¶ Sets up printing to the given file. If `fp` is omitted, `sys.stdout.buffer` is assumed. begin_document(_id : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PSDraw.html#PSDraw.begin_document)¶ Set up printing of a document. (Write PostScript DSC header.) end_document() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PSDraw.html#PSDraw.end_document)¶ Ends printing. (Write PostScript DSC footer.) image(_box : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _im : [Image.Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _dpi : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PSDraw.html#PSDraw.image)¶ Draw a PIL image, centered in the given box. line(_xy0 : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _xy1 : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PSDraw.html#PSDraw.line)¶ Draws a line between the two points. Coordinates are given in PostScript point coordinates (72 points per inch, (0, 0) is the lower left corner of the page). rectangle(_box : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PSDraw.html#PSDraw.rectangle)¶ Draws a rectangle. Parameters: **box** – A tuple of four integers, specifying left, bottom, width and height. setfont(_font : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _size : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PSDraw.html#PSDraw.setfont)¶ Selects which font to use. Parameters: * **font** – A PostScript font name * **size** – Size in points. text(_xy : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _text : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PSDraw.html#PSDraw.text)¶ Draws text at the given position. You must use `setfont()` before calling this method. [ Next `PixelAccess` class ](PixelAccess.html) [ Previous `JpegPresets` module ](JpegPresets.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `PSDraw` module * `PSDraw` * `PSDraw.begin_document()` * `PSDraw.end_document()` * `PSDraw.image()` * `PSDraw.line()` * `PSDraw.rectangle()` * `PSDraw.setfont()` * `PSDraw.text()` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/features.html # Path: reference/features.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * `features` module * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/features.rst.txt "View this page") # `features` module¶ The `PIL.features` module can be used to detect which Pillow features are available on your system. PIL.features.pilinfo(_out : [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _supported_formats : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = True_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/features.html#pilinfo)¶ Prints information about this installation of Pillow. This function can be called with `python3 -m PIL`. It can also be called with `python3 -m PIL.report` or `python3 -m PIL --report` to have “supported_formats” set to `False`, omitting the list of all supported image file formats. Parameters: * **out** – The output stream to print to. Defaults to `sys.stdout` if `None`. * **supported_formats** – If `True`, a list of all supported image file formats will be printed. PIL.features.check(_feature : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/features.html#check)¶ Parameters: **feature** – A module, codec, or feature name. Returns: `True` if the module, codec, or feature is available, `False` or `None` otherwise. PIL.features.version(_feature : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/features.html#version)¶ Parameters: **feature** – The module, codec, or feature to check for. Returns: The version number as a string, or `None` if unknown or not available. PIL.features.get_supported() -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")][[source]](../_modules/PIL/features.html#get_supported)¶ Returns: A list of all supported modules, features, and codecs. ## Modules¶ Support for the following modules can be checked: * `pil`: The Pillow core module, required for all functionality. * `tkinter`: Tkinter support. * `freetype2`: FreeType font support via [`PIL.ImageFont.truetype()`](ImageFont.html#PIL.ImageFont.truetype "PIL.ImageFont.truetype"). * `littlecms2`: LittleCMS 2 support via [`PIL.ImageCms`](ImageCms.html#module-PIL.ImageCms "PIL.ImageCms"). * `webp`: WebP image support. * `avif`: AVIF image support. PIL.features.check_module(_feature : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)")[[source]](../_modules/PIL/features.html#check_module)¶ Checks if a module is available. Parameters: **feature** – The module to check for. Returns: `True` if available, `False` otherwise. Raises: [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "\(in Python v3.14\)") – If the module is not defined in this version of Pillow. PIL.features.version_module(_feature : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/features.html#version_module)¶ Parameters: **feature** – The module to check for. Returns: The loaded version number as a string, or `None` if unknown or not available. Raises: [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "\(in Python v3.14\)") – If the module is not defined in this version of Pillow. PIL.features.get_supported_modules() -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")][[source]](../_modules/PIL/features.html#get_supported_modules)¶ Returns: A list of all supported modules. ## Codecs¶ Support for these is only checked during Pillow compilation. If the required library was uninstalled from the system, the `pil` core module may fail to load instead. Except for `jpg`, the version number is checked at run-time. Support for the following codecs can be checked: * `jpg`: (compile time) Libjpeg support, required for JPEG based image formats. Only compile time version number is available. * `jpg_2000`: (compile time) OpenJPEG support, required for JPEG 2000 image formats. * `zlib`: (compile time) Zlib support, required for zlib compressed formats, such as PNG. * `libtiff`: (compile time) LibTIFF support, required for TIFF based image formats. PIL.features.check_codec(_feature : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)")[[source]](../_modules/PIL/features.html#check_codec)¶ Checks if a codec is available. Parameters: **feature** – The codec to check for. Returns: `True` if available, `False` otherwise. Raises: [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "\(in Python v3.14\)") – If the codec is not defined in this version of Pillow. PIL.features.version_codec(_feature : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/features.html#version_codec)¶ Parameters: **feature** – The codec to check for. Returns: The version number as a string, or `None` if not available. Checked at compile time for `jpg`, run-time otherwise. Raises: [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "\(in Python v3.14\)") – If the codec is not defined in this version of Pillow. PIL.features.get_supported_codecs() -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")][[source]](../_modules/PIL/features.html#get_supported_codecs)¶ Returns: A list of all supported codecs. ## Features¶ Some of these are only checked during Pillow compilation. If the required library was uninstalled from the system, the relevant module may fail to load instead. Feature version numbers are available only where stated. Support for the following features can be checked: * `libjpeg_turbo`: (compile time) Whether Pillow was compiled against the libjpeg-turbo version of libjpeg. Compile-time version number is available. * `mozjpeg`: (compile time) Whether Pillow was compiled against the MozJPEG version of libjpeg. Compile-time version number is available. * `zlib_ng`: (compile time) Whether Pillow was compiled against the zlib-ng version of zlib. Compile-time version number is available. * `raqm`: Raqm library, required for `ImageFont.Layout.RAQM` in [`PIL.ImageFont.truetype()`](ImageFont.html#PIL.ImageFont.truetype "PIL.ImageFont.truetype"). Run-time version number is available for Raqm 0.7.0 or newer. * `libimagequant`: (compile time) ImageQuant quantization support in [`PIL.Image.Image.quantize()`](Image.html#PIL.Image.Image.quantize "PIL.Image.Image.quantize"). Run-time version number is available. * `xcb`: (compile time) Support for X11 in [`PIL.ImageGrab.grab()`](ImageGrab.html#PIL.ImageGrab.grab "PIL.ImageGrab.grab") via the XCB library. PIL.features.check_feature(_feature : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/features.html#check_feature)¶ Checks if a feature is available. Parameters: **feature** – The feature to check for. Returns: `True` if available, `False` if unavailable, `None` if unknown. Raises: [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "\(in Python v3.14\)") – If the feature is not defined in this version of Pillow. PIL.features.version_feature(_feature : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/features.html#version_feature)¶ Parameters: **feature** – The feature to check for. Returns: The version number as a string, or `None` if not available. Raises: [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "\(in Python v3.14\)") – If the feature is not defined in this version of Pillow. PIL.features.get_supported_features() -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")][[source]](../_modules/PIL/features.html#get_supported_features)¶ Returns: A list of all supported features. [ Next PIL package (autodoc of remaining modules) ](../PIL.html) [ Previous `PixelAccess` class ](PixelAccess.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * `features` module * `pilinfo()` * `check()` * `version()` * `get_supported()` * Modules * `check_module()` * `version_module()` * `get_supported_modules()` * Codecs * `check_codec()` * `version_codec()` * `get_supported_codecs()` * Features * `check_feature()` * `version_feature()` * `get_supported_features()` --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/index.html # Path: reference/index.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * Reference * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * [Plugin reference](plugins.html) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/index.rst.txt "View this page") # Reference¶ * [`Image` module](Image.html) * [Examples](Image.html#examples) * [Functions](Image.html#functions) * [The Image class](Image.html#the-image-class) * [Image attributes](Image.html#image-attributes) * [Classes](Image.html#classes) * [Protocols](Image.html#protocols) * [Constants](Image.html#constants) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [Functions](ImageChops.html#functions) * [`ImageCms` module](ImageCms.html) * [`ImageCmsProfile`](ImageCms.html#PIL.ImageCms.ImageCmsProfile) * [`ImageCmsTransform`](ImageCms.html#PIL.ImageCms.ImageCmsTransform) * [`PyCMSError`](ImageCms.html#PIL.ImageCms.PyCMSError) * [Constants](ImageCms.html#constants) * [Functions](ImageCms.html#functions) * [CmsProfile](ImageCms.html#cmsprofile) * [`ImageColor` module](ImageColor.html) * [Color names](ImageColor.html#color-names) * [Functions](ImageColor.html#functions) * [`ImageDraw` module](ImageDraw.html) * [Example: Draw a gray cross over an image](ImageDraw.html#example-draw-a-gray-cross-over-an-image) * [Concepts](ImageDraw.html#concepts) * [Example: Draw partial opacity text](ImageDraw.html#example-draw-partial-opacity-text) * [Example: Draw multiline text](ImageDraw.html#example-draw-multiline-text) * [Functions](ImageDraw.html#functions) * [Attributes](ImageDraw.html#attributes) * [Methods](ImageDraw.html#methods) * [`ImageEnhance` module](ImageEnhance.html) * [Example: Vary the sharpness of an image](ImageEnhance.html#example-vary-the-sharpness-of-an-image) * [Classes](ImageEnhance.html#classes) * [`ImageFile` module](ImageFile.html) * [Example: Parse an image](ImageFile.html#example-parse-an-image) * [Classes](ImageFile.html#classes) * [Constants](ImageFile.html#constants) * [`ImageFilter` module](ImageFilter.html) * [Example: Filter an image](ImageFilter.html#example-filter-an-image) * [Filters](ImageFilter.html#filters) * [`ImageFont` module](ImageFont.html) * [Example](ImageFont.html#example) * [Functions](ImageFont.html#functions) * [Methods](ImageFont.html#methods) * [Constants](ImageFont.html#constants) * [Dictionaries](ImageFont.html#dictionaries) * [`ImageGrab` module](ImageGrab.html) * [`grab()`](ImageGrab.html#PIL.ImageGrab.grab) * [`grabclipboard()`](ImageGrab.html#PIL.ImageGrab.grabclipboard) * [`ImageMath` module](ImageMath.html) * [Example: Using the `ImageMath` module](ImageMath.html#example-using-the-imagemath-module) * [Expression syntax](ImageMath.html#expression-syntax) * [`ImageMorph` module](ImageMorph.html) * [`LutBuilder`](ImageMorph.html#PIL.ImageMorph.LutBuilder) * [`MorphOp`](ImageMorph.html#PIL.ImageMorph.MorphOp) * [`ImageOps` module](ImageOps.html) * [`autocontrast()`](ImageOps.html#PIL.ImageOps.autocontrast) * [`colorize()`](ImageOps.html#PIL.ImageOps.colorize) * [`crop()`](ImageOps.html#PIL.ImageOps.crop) * [`scale()`](ImageOps.html#PIL.ImageOps.scale) * [`SupportsGetMesh`](ImageOps.html#PIL.ImageOps.SupportsGetMesh) * [`deform()`](ImageOps.html#PIL.ImageOps.deform) * [`equalize()`](ImageOps.html#PIL.ImageOps.equalize) * [`expand()`](ImageOps.html#PIL.ImageOps.expand) * [`flip()`](ImageOps.html#PIL.ImageOps.flip) * [`grayscale()`](ImageOps.html#PIL.ImageOps.grayscale) * [`invert()`](ImageOps.html#PIL.ImageOps.invert) * [`mirror()`](ImageOps.html#PIL.ImageOps.mirror) * [`posterize()`](ImageOps.html#PIL.ImageOps.posterize) * [`solarize()`](ImageOps.html#PIL.ImageOps.solarize) * [`exif_transpose()`](ImageOps.html#PIL.ImageOps.exif_transpose) * [Resize relative to a given size](ImageOps.html#resize-relative-to-a-given-size) * [`ImagePalette` module](ImagePalette.html) * [`ImagePalette`](ImagePalette.html#PIL.ImagePalette.ImagePalette) * [`ImagePath` module](ImagePath.html) * [`PIL.ImagePath.Path`](ImagePath.html#PIL.ImagePath.PIL.ImagePath.Path) * [`PIL.ImagePath.Path.compact()`](ImagePath.html#PIL.ImagePath.PIL.ImagePath.Path.compact) * [`PIL.ImagePath.Path.getbbox()`](ImagePath.html#PIL.ImagePath.PIL.ImagePath.Path.getbbox) * [`PIL.ImagePath.Path.map()`](ImagePath.html#PIL.ImagePath.PIL.ImagePath.Path.map) * [`PIL.ImagePath.Path.tolist()`](ImagePath.html#PIL.ImagePath.PIL.ImagePath.Path.tolist) * [`PIL.ImagePath.Path.transform()`](ImagePath.html#PIL.ImagePath.PIL.ImagePath.Path.transform) * [`ImageQt` module](ImageQt.html) * [`ImageQt`](ImageQt.html#PIL.ImageQt.ImageQt) * [`ImageSequence` module](ImageSequence.html) * [Extracting frames from an animation](ImageSequence.html#extracting-frames-from-an-animation) * [The `Iterator` class](ImageSequence.html#the-iterator-class) * [Functions](ImageSequence.html#functions) * [`ImageShow` module](ImageShow.html) * [`show()`](ImageShow.html#PIL.ImageShow.show) * [`IPythonViewer`](ImageShow.html#PIL.ImageShow.IPythonViewer) * [`WindowsViewer`](ImageShow.html#PIL.ImageShow.WindowsViewer) * [`MacViewer`](ImageShow.html#PIL.ImageShow.MacViewer) * [`UnixViewer`](ImageShow.html#PIL.ImageShow.UnixViewer) * [`register()`](ImageShow.html#PIL.ImageShow.register) * [`Viewer`](ImageShow.html#PIL.ImageShow.Viewer) * [`ImageStat` module](ImageStat.html) * [`Stat`](ImageStat.html#PIL.ImageStat.Stat) * [`ImageText` module](ImageText.html) * [Example](ImageText.html#example) * [Comparison](ImageText.html#comparison) * [Methods](ImageText.html#methods) * [`ImageTk` module](ImageTk.html) * [`BitmapImage`](ImageTk.html#PIL.ImageTk.BitmapImage) * [`PhotoImage`](ImageTk.html#PIL.ImageTk.PhotoImage) * [`ImageTransform` module](ImageTransform.html) * [`Transform`](ImageTransform.html#PIL.ImageTransform.Transform) * [`AffineTransform`](ImageTransform.html#PIL.ImageTransform.AffineTransform) * [`PerspectiveTransform`](ImageTransform.html#PIL.ImageTransform.PerspectiveTransform) * [`ExtentTransform`](ImageTransform.html#PIL.ImageTransform.ExtentTransform) * [`QuadTransform`](ImageTransform.html#PIL.ImageTransform.QuadTransform) * [`MeshTransform`](ImageTransform.html#PIL.ImageTransform.MeshTransform) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`Dib`](ImageWin.html#PIL.ImageWin.Dib) * [`HDC`](ImageWin.html#PIL.ImageWin.HDC) * [`HWND`](ImageWin.html#PIL.ImageWin.HWND) * [`ExifTags` module](ExifTags.html) * [`Base`](ExifTags.html#PIL.ExifTags.Base) * [`GPS`](ExifTags.html#PIL.ExifTags.GPS) * [`Interop`](ExifTags.html#PIL.ExifTags.Interop) * [`IFD`](ExifTags.html#PIL.ExifTags.IFD) * [`LightSource`](ExifTags.html#PIL.ExifTags.LightSource) * [`TAGS`](ExifTags.html#PIL.ExifTags.TAGS) * [`GPSTAGS`](ExifTags.html#PIL.ExifTags.GPSTAGS) * [`TiffTags` module](TiffTags.html) * [`lookup()`](TiffTags.html#PIL.TiffTags.lookup) * [`TagInfo`](TiffTags.html#PIL.TiffTags.TagInfo) * [`PIL.TiffTags.TAGS_V2`](TiffTags.html#PIL.TiffTags.PIL.TiffTags.TAGS_V2) * [`PIL.TiffTags.TAGS_V2_GROUPS`](TiffTags.html#PIL.TiffTags.PIL.TiffTags.TAGS_V2_GROUPS) * [`PIL.TiffTags.TAGS`](TiffTags.html#PIL.TiffTags.PIL.TiffTags.TAGS) * [`PIL.TiffTags.TYPES`](TiffTags.html#PIL.TiffTags.PIL.TiffTags.TYPES) * [`PIL.TiffTags.LIBTIFF_CORE`](TiffTags.html#PIL.TiffTags.PIL.TiffTags.LIBTIFF_CORE) * [`JpegPresets` module](JpegPresets.html) * [Subsampling](JpegPresets.html#subsampling) * [Quantization tables](JpegPresets.html#quantization-tables) * [`PSDraw` module](PSDraw.html) * [`PSDraw`](PSDraw.html#PIL.PSDraw.PSDraw) * [`PixelAccess` class](PixelAccess.html) * [Example](PixelAccess.html#example) * [`PixelAccess` class](PixelAccess.html#id1) * [`features` module](features.html) * [`pilinfo()`](features.html#PIL.features.pilinfo) * [`check()`](features.html#PIL.features.check) * [`version()`](features.html#PIL.features.version) * [`get_supported()`](features.html#PIL.features.get_supported) * [Modules](features.html#modules) * [Codecs](features.html#codecs) * [Features](features.html#features) * [PIL package (autodoc of remaining modules)](../PIL.html) * [`PIL` module](../PIL.html#module-PIL) * [`BdfFontFile` module](../PIL.html#module-PIL.BdfFontFile) * [`ContainerIO` module](../PIL.html#module-PIL.ContainerIO) * [`FontFile` module](../PIL.html#module-PIL.FontFile) * [`GdImageFile` module](../PIL.html#module-PIL.GdImageFile) * [`GimpGradientFile` module](../PIL.html#module-PIL.GimpGradientFile) * [`GimpPaletteFile` module](../PIL.html#module-PIL.GimpPaletteFile) * [`ImageDraw2` module](../PIL.html#module-PIL.ImageDraw2) * [`ImageMode` module](../PIL.html#module-PIL.ImageMode) * [`PaletteFile` module](../PIL.html#module-PIL.PaletteFile) * [`PcfFontFile` module](../PIL.html#module-PIL.PcfFontFile) * [`PngImagePlugin.iTXt` class](../PIL.html#pngimageplugin-itxt-class) * [`PngImagePlugin.PngInfo` class](../PIL.html#pngimageplugin-pnginfo-class) * [`TarIO` module](../PIL.html#module-PIL.TarIO) * [`WalImageFile` module](../PIL.html#module-PIL.WalImageFile) * [Plugin reference](plugins.html) * [`AvifImagePlugin` module](plugins.html#module-PIL.AvifImagePlugin) * [`BmpImagePlugin` module](plugins.html#module-PIL.BmpImagePlugin) * [`BufrStubImagePlugin` module](plugins.html#module-PIL.BufrStubImagePlugin) * [`CurImagePlugin` module](plugins.html#module-PIL.CurImagePlugin) * [`DcxImagePlugin` module](plugins.html#module-PIL.DcxImagePlugin) * [`DdsImagePlugin` module](plugins.html#module-PIL.DdsImagePlugin) * [`EpsImagePlugin` module](plugins.html#module-PIL.EpsImagePlugin) * [`FitsImagePlugin` module](plugins.html#module-PIL.FitsImagePlugin) * [`FliImagePlugin` module](plugins.html#module-PIL.FliImagePlugin) * [`FpxImagePlugin` module](plugins.html#module-PIL.FpxImagePlugin) * [`GbrImagePlugin` module](plugins.html#module-PIL.GbrImagePlugin) * [`GifImagePlugin` module](plugins.html#module-PIL.GifImagePlugin) * [`GribStubImagePlugin` module](plugins.html#module-PIL.GribStubImagePlugin) * [`Hdf5StubImagePlugin` module](plugins.html#module-PIL.Hdf5StubImagePlugin) * [`IcnsImagePlugin` module](plugins.html#module-PIL.IcnsImagePlugin) * [`IcoImagePlugin` module](plugins.html#module-PIL.IcoImagePlugin) * [`ImImagePlugin` module](plugins.html#module-PIL.ImImagePlugin) * [`ImtImagePlugin` module](plugins.html#module-PIL.ImtImagePlugin) * [`IptcImagePlugin` module](plugins.html#module-PIL.IptcImagePlugin) * [`JpegImagePlugin` module](plugins.html#module-PIL.JpegImagePlugin) * [`Jpeg2KImagePlugin` module](plugins.html#module-PIL.Jpeg2KImagePlugin) * [`McIdasImagePlugin` module](plugins.html#module-PIL.McIdasImagePlugin) * [`MicImagePlugin` module](plugins.html#module-PIL.MicImagePlugin) * [`MpegImagePlugin` module](plugins.html#module-PIL.MpegImagePlugin) * [`MpoImagePlugin` module](plugins.html#module-PIL.MpoImagePlugin) * [`MspImagePlugin` module](plugins.html#module-PIL.MspImagePlugin) * [`PalmImagePlugin` module](plugins.html#module-PIL.PalmImagePlugin) * [`PcdImagePlugin` module](plugins.html#module-PIL.PcdImagePlugin) * [`PcxImagePlugin` module](plugins.html#module-PIL.PcxImagePlugin) * [`PdfImagePlugin` module](plugins.html#module-PIL.PdfImagePlugin) * [`PixarImagePlugin` module](plugins.html#module-PIL.PixarImagePlugin) * [`PngImagePlugin` module](plugins.html#module-PIL.PngImagePlugin) * [`PpmImagePlugin` module](plugins.html#module-PIL.PpmImagePlugin) * [`PsdImagePlugin` module](plugins.html#module-PIL.PsdImagePlugin) * [`SgiImagePlugin` module](plugins.html#module-PIL.SgiImagePlugin) * [`SpiderImagePlugin` module](plugins.html#module-PIL.SpiderImagePlugin) * [`SunImagePlugin` module](plugins.html#module-PIL.SunImagePlugin) * [`TgaImagePlugin` module](plugins.html#module-PIL.TgaImagePlugin) * [`TiffImagePlugin` module](plugins.html#module-PIL.TiffImagePlugin) * [`WebPImagePlugin` module](plugins.html#module-PIL.WebPImagePlugin) * [`WmfImagePlugin` module](plugins.html#module-PIL.WmfImagePlugin) * [`XVThumbImagePlugin` module](plugins.html#module-PIL.XVThumbImagePlugin) * [`XbmImagePlugin` module](plugins.html#module-PIL.XbmImagePlugin) * [`XpmImagePlugin` module](plugins.html#module-PIL.XpmImagePlugin) * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) [ Next `Image` module ](Image.html) [ Previous Writing your own image plugin ](../handbook/writing-your-own-image-plugin.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) --- # Pillow Documentation # Source: https://pillow.readthedocs.io/en/latest/reference/plugins.html # Path: reference/plugins.html Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content [Pillow (PIL Fork) 12.1.0.dev0 documentation](../index.html) [ ![Light Logo](../_static/pillow-logo-dark-text.png) ![Dark Logo](../_static/pillow-logo.png) Pillow (PIL Fork) 12.1.0.dev0 documentation ](../index.html) * [Installation](../installation/index.html) * [Basic installation](../installation/basic-installation.html) * [Python support](../installation/python-support.html) * [Platform support](../installation/platform-support.html) * [Building from source](../installation/building-from-source.html) * [Old versions](../installation/building-from-source.html#old-versions) * [Handbook](../handbook/index.html) * [Overview](../handbook/overview.html) * [Tutorial](../handbook/tutorial.html) * [Concepts](../handbook/concepts.html) * [Appendices](../handbook/appendices.html) * [Image file formats](../handbook/image-file-formats.html) * [Text anchors](../handbook/text-anchors.html) * [Third-party plugins](../handbook/third-party-plugins.html) * [Writing your own image plugin](../handbook/writing-your-own-image-plugin.html) * [Decoders](../handbook/writing-your-own-image-plugin.html#decoders) * [Writing your own file codec in C](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-c) * [Writing your own file codec in Python](../handbook/writing-your-own-image-plugin.html#writing-your-own-file-codec-in-python) * [Reference](index.html) * [`Image` module](Image.html) * [`ImageChops` (“channel operations”) module](ImageChops.html) * [`ImageCms` module](ImageCms.html) * [`ImageColor` module](ImageColor.html) * [`ImageDraw` module](ImageDraw.html) * [`ImageEnhance` module](ImageEnhance.html) * [`ImageFile` module](ImageFile.html) * [`ImageFilter` module](ImageFilter.html) * [`ImageFont` module](ImageFont.html) * [`ImageGrab` module](ImageGrab.html) * [`ImageMath` module](ImageMath.html) * [`ImageMorph` module](ImageMorph.html) * [`ImageOps` module](ImageOps.html) * [`ImagePalette` module](ImagePalette.html) * [`ImagePath` module](ImagePath.html) * [`ImageQt` module](ImageQt.html) * [`ImageSequence` module](ImageSequence.html) * [`ImageShow` module](ImageShow.html) * [`ImageStat` module](ImageStat.html) * [`ImageText` module](ImageText.html) * [`ImageTk` module](ImageTk.html) * [`ImageTransform` module](ImageTransform.html) * [`ImageWin` module (Windows-only)](ImageWin.html) * [`ExifTags` module](ExifTags.html) * [`TiffTags` module](TiffTags.html) * [`JpegPresets` module](JpegPresets.html) * [`PSDraw` module](PSDraw.html) * [`PixelAccess` class](PixelAccess.html) * [`features` module](features.html) * [PIL package (autodoc of remaining modules)](../PIL.html) * Plugin reference * [Internal reference](internal_design.html) * [File handling in Pillow](open_files.html) * [Limits](limits.html) * [Block allocator](block_allocator.html) * [Internal modules](internal_modules.html) * [C extension debugging on Linux, with GBD/Valgrind](c_extension_debugging.html) * [Arrow support](arrow_support.html) * [Porting](../porting.html) * [About](../about.html) * [Release notes](../releasenotes/index.html) * [Versioning](../releasenotes/versioning.html) * [12.1.0 (unreleased)](../releasenotes/12.1.0.html) * [12.0.0 (2025-10-15)](../releasenotes/12.0.0.html) * [11.3.0 (2025-07-01)](../releasenotes/11.3.0.html) * [11.2.1 (2025-04-12)](../releasenotes/11.2.1.html) * [11.1.0 (2025-01-02)](../releasenotes/11.1.0.html) * [11.0.0 (2024-10-15)](../releasenotes/11.0.0.html) * [10.4.0 (2024-07-01)](../releasenotes/10.4.0.html) * [10.3.0 (2024-04-01)](../releasenotes/10.3.0.html) * [10.2.0 (2024-01-02)](../releasenotes/10.2.0.html) * [10.1.0 (2023-10-15)](../releasenotes/10.1.0.html) * [10.0.1 (2023-09-15)](../releasenotes/10.0.1.html) * [10.0.0 (2023-07-01)](../releasenotes/10.0.0.html) * [9.5.0 (2023-04-01)](../releasenotes/9.5.0.html) * [9.4.0 (2023-01-02)](../releasenotes/9.4.0.html) * [9.3.0 (2022-10-29)](../releasenotes/9.3.0.html) * [9.2.0 (2022-07-01)](../releasenotes/9.2.0.html) * [9.1.1 (2022-05-17)](../releasenotes/9.1.1.html) * [9.1.0 (2022-04-01)](../releasenotes/9.1.0.html) * [9.0.1 (2022-02-03)](../releasenotes/9.0.1.html) * [9.0.0 (2022-01-02)](../releasenotes/9.0.0.html) * [8.4.0 (2021-10-15)](../releasenotes/8.4.0.html) * [8.3.2 (2021-09-02)](../releasenotes/8.3.2.html) * [8.3.1 (2021-07-06)](../releasenotes/8.3.1.html) * [8.3.0 (2021-07-01)](../releasenotes/8.3.0.html) * [8.2.0 (2021-04-01)](../releasenotes/8.2.0.html) * [8.1.2 (2021-03-06)](../releasenotes/8.1.2.html) * [8.1.1 (2021-03-01)](../releasenotes/8.1.1.html) * [8.1.0 (2021-01-02)](../releasenotes/8.1.0.html) * [8.0.1 (2020-10-22)](../releasenotes/8.0.1.html) * [8.0.0 (2020-10-14)](../releasenotes/8.0.0.html) * [7.2.0 (2020-06-30)](../releasenotes/7.2.0.html) * [7.1.2 (2020-04-25)](../releasenotes/7.1.2.html) * [7.1.1 (2020-04-02)](../releasenotes/7.1.1.html) * [7.1.0 (2020-04-01)](../releasenotes/7.1.0.html) * [7.0.0 (2020-01-02)](../releasenotes/7.0.0.html) * [6.2.2 (2020-01-02)](../releasenotes/6.2.2.html) * [6.2.1 (2019-10-20)](../releasenotes/6.2.1.html) * [6.2.0 (2019-10-01)](../releasenotes/6.2.0.html) * [6.1.0 (2019-07-02)](../releasenotes/6.1.0.html) * [6.0.0 (2019-04-02)](../releasenotes/6.0.0.html) * [5.4.1 (2019-01-06)](../releasenotes/5.4.1.html) * [5.4.0 (2019-01-01)](../releasenotes/5.4.0.html) * [5.3.0 (2018-10-01)](../releasenotes/5.3.0.html) * [5.2.0 (2018-07-01)](../releasenotes/5.2.0.html) * [5.1.0 (2018-04-02)](../releasenotes/5.1.0.html) * [5.0.0 (2018-01-01)](../releasenotes/5.0.0.html) * [4.3.0 (2017-10-02)](../releasenotes/4.3.0.html) * [4.2.1 (2017-07-06)](../releasenotes/4.2.1.html) * [4.2.0 (2017-07-01)](../releasenotes/4.2.0.html) * [4.1.1 (2017-04-28)](../releasenotes/4.1.1.html) * [4.1.0 (2017-04-03)](../releasenotes/4.1.0.html) * [4.0.0 (2017-01-01)](../releasenotes/4.0.0.html) * [3.4.0 (2016-10-03)](../releasenotes/3.4.0.html) * [3.3.2 (2016-09-29)](../releasenotes/3.3.2.html) * [3.3.0 (2016-07-01)](../releasenotes/3.3.0.html) * [3.2.0 (2016-04-01)](../releasenotes/3.2.0.html) * [3.1.2 (2016-04-01)](../releasenotes/3.1.2.html) * [3.1.1 (2016-02-04)](../releasenotes/3.1.1.html) * [3.1.0 (2016-01-04)](../releasenotes/3.1.0.html) * [3.0.0 (2015-10-01)](../releasenotes/3.0.0.html) * [2.8.0 (2015-04-01)](../releasenotes/2.8.0.html) * [2.7.0 (2014-12-31)](../releasenotes/2.7.0.html) * [2.6.0 (2014-10-01)](../releasenotes/2.6.0.html) * [2.5.2 (2014-08-12)](../releasenotes/2.5.2.html) * [2.3.2 (2014-08-12)](../releasenotes/2.3.2.html) * [2.3.1 (2014-03-14)](../releasenotes/2.3.1.html) * [Deprecations and removals](../deprecations.html) Back to top [ View this page ](../_sources/reference/plugins.rst.txt "View this page") # Plugin reference¶ ## `AvifImagePlugin` module¶ class PIL.AvifImagePlugin.AvifImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/AvifImagePlugin.html#AvifImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'AVIF'¶ format_description = 'AVIF image'¶ load() -> [Image.core.PixelAccess](PixelAccess.html#PixelAccess "PIL.Image.core.PixelAccess") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/AvifImagePlugin.html#AvifImageFile.load)¶ Load image data based on tile list load_seek(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/AvifImagePlugin.html#AvifImageFile.load_seek)¶ seek(_frame : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/AvifImagePlugin.html#AvifImageFile.seek)¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an `EOFError` exception. When a sequence file is opened, the library automatically seeks to frame 0. See [`tell()`](Image.html#PIL.Image.Image.tell "PIL.Image.Image.tell"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Parameters: **frame** – Frame number, starting at 0. Raises: [**EOFError**](https://docs.python.org/3/library/exceptions.html#EOFError "\(in Python v3.14\)") – If the call attempts to seek beyond the end of the sequence. tell() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/AvifImagePlugin.html#AvifImageFile.tell)¶ Returns the current frame number. See [`seek()`](Image.html#PIL.Image.Image.seek "PIL.Image.Image.seek"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Returns: Frame number, starting with 0. PIL.AvifImagePlugin.get_codec_version(_codec_name : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/AvifImagePlugin.html#get_codec_version)¶ ## `BmpImagePlugin` module¶ class PIL.BmpImagePlugin.BmpImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/BmpImagePlugin.html#BmpImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") Image plugin for the Windows Bitmap format (BMP) BITFIELDS = 3¶ COMPRESSIONS = {'BITFIELDS': 3, 'JPEG': 4, 'PNG': 5, 'RAW': 0, 'RLE4': 2, 'RLE8': 1}¶ JPEG = 4¶ PNG = 5¶ RAW = 0¶ RLE4 = 2¶ RLE8 = 1¶ format = 'BMP'¶ format_description = 'Windows Bitmap'¶ k = 'PNG'¶ v = 5¶ class PIL.BmpImagePlugin.BmpRleDecoder(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _* args: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_)[[source]](../_modules/PIL/BmpImagePlugin.html#BmpRleDecoder)¶ Bases: [`PyDecoder`](ImageFile.html#PIL.ImageFile.PyDecoder "PIL.ImageFile.PyDecoder") decode(_buffer : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [SupportsArrayInterface](Image.html#PIL.Image.SupportsArrayInterface "PIL.Image.SupportsArrayInterface")_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/BmpImagePlugin.html#BmpRleDecoder.decode)¶ Override to perform the decoding process. Parameters: **buffer** – A bytes object with the data to be decoded. Returns: A tuple of `(bytes consumed, errcode)`. If finished with decoding return -1 for the bytes consumed. Err codes are from [`ImageFile.ERRORS`](ImageFile.html#PIL.ImageFile.ERRORS "PIL.ImageFile.ERRORS"). class PIL.BmpImagePlugin.DibImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/BmpImagePlugin.html#DibImageFile)¶ Bases: `BmpImageFile` format = 'DIB'¶ format_description = 'Windows Bitmap'¶ ## `BufrStubImagePlugin` module¶ class PIL.BufrStubImagePlugin.BufrStubImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/BufrStubImagePlugin.html#BufrStubImageFile)¶ Bases: [`StubImageFile`](ImageFile.html#PIL.ImageFile.StubImageFile "PIL.ImageFile.StubImageFile") format = 'BUFR'¶ format_description = 'BUFR'¶ PIL.BufrStubImagePlugin.register_handler(_handler : [StubHandler](ImageFile.html#PIL.ImageFile.StubHandler "PIL.ImageFile.StubHandler") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/BufrStubImagePlugin.html#register_handler)¶ Install application-specific BUFR image handler. Parameters: **handler** – Handler object. ## `CurImagePlugin` module¶ class PIL.CurImagePlugin.CurImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/CurImagePlugin.html#CurImageFile)¶ Bases: `BmpImageFile` format = 'CUR'¶ format_description = 'Windows Cursor'¶ ## `DcxImagePlugin` module¶ class PIL.DcxImagePlugin.DcxImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/DcxImagePlugin.html#DcxImageFile)¶ Bases: `PcxImageFile` format = 'DCX'¶ format_description = 'Intel DCX'¶ seek(_frame : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/DcxImagePlugin.html#DcxImageFile.seek)¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an `EOFError` exception. When a sequence file is opened, the library automatically seeks to frame 0. See [`tell()`](Image.html#PIL.Image.Image.tell "PIL.Image.Image.tell"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Parameters: **frame** – Frame number, starting at 0. Raises: [**EOFError**](https://docs.python.org/3/library/exceptions.html#EOFError "\(in Python v3.14\)") – If the call attempts to seek beyond the end of the sequence. tell() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/DcxImagePlugin.html#DcxImageFile.tell)¶ Returns the current frame number. See [`seek()`](Image.html#PIL.Image.Image.seek "PIL.Image.Image.seek"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Returns: Frame number, starting with 0. ## `DdsImagePlugin` module¶ A Pillow plugin for .dds files (S3TC-compressed aka DXTC) Jerome Leclanche <[jerome@leclan.ch](mailto:jerome%40leclan.ch)> Documentation: The contents of this file are hereby released in the public domain (CC0) Full text of the CC0 license: class PIL.DdsImagePlugin.D3DFMT(_* values_)[[source]](../_modules/PIL/DdsImagePlugin.html#D3DFMT)¶ Bases: [`IntEnum`](https://docs.python.org/3/library/enum.html#enum.IntEnum "\(in Python v3.14\)") A1 = 118¶ A16B16G16R16 = 36¶ A16B16G16R16F = 113¶ A1R5G5B5 = 25¶ A2B10G10R10 = 31¶ A2B10G10R10_XR_BIAS = 119¶ A2R10G10B10 = 35¶ A2W10V10U10 = 67¶ A32B32G32R32F = 116¶ A4L4 = 52¶ A4R4G4B4 = 26¶ A8 = 28¶ A8B8G8R8 = 32¶ A8L8 = 51¶ A8P8 = 40¶ A8R3G3B2 = 29¶ A8R8G8B8 = 21¶ ATI1 = 826889281¶ ATI2 = 843666497¶ BC4S = 1395934018¶ BC4U = 1429488450¶ BC5S = 1395999554¶ BC5U = 1429553986¶ BINARYBUFFER = 199¶ CxV8U8 = 117¶ D15S1 = 73¶ D16 = 80¶ D16_LOCKABLE = 70¶ D24FS8 = 83¶ D24S8 = 75¶ D24X4S4 = 79¶ D24X8 = 77¶ D32 = 71¶ D32F_LOCKABLE = 82¶ D32_LOCKABLE = 84¶ DX10 = 808540228¶ DXT1 = 827611204¶ DXT2 = 844388420¶ DXT3 = 861165636¶ DXT4 = 877942852¶ DXT5 = 894720068¶ G16R16 = 34¶ G16R16F = 112¶ G32R32F = 115¶ G8R8_G8B8 = 1111970375¶ INDEX16 = 101¶ INDEX32 = 102¶ L16 = 81¶ L6V5U5 = 61¶ L8 = 50¶ MULTI2_ARGB8 = 827606349¶ P8 = 41¶ Q16W16V16U16 = 110¶ Q8W8V8U8 = 63¶ R16F = 111¶ R32F = 114¶ R3G3B2 = 27¶ R5G6B5 = 23¶ R8G8B8 = 20¶ R8G8_B8G8 = 1195525970¶ S8_LOCKABLE = 85¶ UNKNOWN = 0¶ UYVY = 1498831189¶ V16U16 = 64¶ V8U8 = 60¶ VERTEXDATA = 100¶ X1R5G5B5 = 24¶ X4R4G4B4 = 30¶ X8B8G8R8 = 33¶ X8L8V8U8 = 62¶ X8R8G8B8 = 22¶ YUY2 = 844715353¶ class PIL.DdsImagePlugin.DDPF(_* values_)[[source]](../_modules/PIL/DdsImagePlugin.html#DDPF)¶ Bases: [`IntFlag`](https://docs.python.org/3/library/enum.html#enum.IntFlag "\(in Python v3.14\)") ALPHA = 2¶ ALPHAPIXELS = 1¶ FOURCC = 4¶ LUMINANCE = 131072¶ PALETTEINDEXED8 = 32¶ RGB = 64¶ class PIL.DdsImagePlugin.DDSCAPS(_* values_)[[source]](../_modules/PIL/DdsImagePlugin.html#DDSCAPS)¶ Bases: [`IntFlag`](https://docs.python.org/3/library/enum.html#enum.IntFlag "\(in Python v3.14\)") COMPLEX = 8¶ MIPMAP = 4194304¶ TEXTURE = 4096¶ class PIL.DdsImagePlugin.DDSCAPS2(_* values_)[[source]](../_modules/PIL/DdsImagePlugin.html#DDSCAPS2)¶ Bases: [`IntFlag`](https://docs.python.org/3/library/enum.html#enum.IntFlag "\(in Python v3.14\)") CUBEMAP = 512¶ CUBEMAP_NEGATIVEX = 2048¶ CUBEMAP_NEGATIVEY = 8192¶ CUBEMAP_NEGATIVEZ = 32768¶ CUBEMAP_POSITIVEX = 1024¶ CUBEMAP_POSITIVEY = 4096¶ CUBEMAP_POSITIVEZ = 16384¶ VOLUME = 2097152¶ class PIL.DdsImagePlugin.DDSD(_* values_)[[source]](../_modules/PIL/DdsImagePlugin.html#DDSD)¶ Bases: [`IntFlag`](https://docs.python.org/3/library/enum.html#enum.IntFlag "\(in Python v3.14\)") CAPS = 1¶ DEPTH = 8388608¶ HEIGHT = 2¶ LINEARSIZE = 524288¶ MIPMAPCOUNT = 131072¶ PITCH = 8¶ PIXELFORMAT = 4096¶ WIDTH = 4¶ class PIL.DdsImagePlugin.DXGI_FORMAT(_* values_)[[source]](../_modules/PIL/DdsImagePlugin.html#DXGI_FORMAT)¶ Bases: [`IntEnum`](https://docs.python.org/3/library/enum.html#enum.IntEnum "\(in Python v3.14\)") A8P8 = 114¶ A8_UNORM = 65¶ AI44 = 111¶ AYUV = 100¶ B4G4R4A4_UNORM = 115¶ B5G5R5A1_UNORM = 86¶ B5G6R5_UNORM = 85¶ B8G8R8A8_TYPELESS = 90¶ B8G8R8A8_UNORM = 87¶ B8G8R8A8_UNORM_SRGB = 91¶ B8G8R8X8_TYPELESS = 92¶ B8G8R8X8_UNORM = 88¶ B8G8R8X8_UNORM_SRGB = 93¶ BC1_TYPELESS = 70¶ BC1_UNORM = 71¶ BC1_UNORM_SRGB = 72¶ BC2_TYPELESS = 73¶ BC2_UNORM = 74¶ BC2_UNORM_SRGB = 75¶ BC3_TYPELESS = 76¶ BC3_UNORM = 77¶ BC3_UNORM_SRGB = 78¶ BC4_SNORM = 81¶ BC4_TYPELESS = 79¶ BC4_UNORM = 80¶ BC5_SNORM = 84¶ BC5_TYPELESS = 82¶ BC5_UNORM = 83¶ BC6H_SF16 = 96¶ BC6H_TYPELESS = 94¶ BC6H_UF16 = 95¶ BC7_TYPELESS = 97¶ BC7_UNORM = 98¶ BC7_UNORM_SRGB = 99¶ D16_UNORM = 55¶ D24_UNORM_S8_UINT = 45¶ D32_FLOAT = 40¶ D32_FLOAT_S8X24_UINT = 20¶ G8R8_G8B8_UNORM = 69¶ IA44 = 112¶ NV11 = 110¶ NV12 = 103¶ OPAQUE_420 = 106¶ P010 = 104¶ P016 = 105¶ P208 = 130¶ P8 = 113¶ R10G10B10A2_TYPELESS = 23¶ R10G10B10A2_UINT = 25¶ R10G10B10A2_UNORM = 24¶ R10G10B10_XR_BIAS_A2_UNORM = 89¶ R11G11B10_FLOAT = 26¶ R16G16B16A16_FLOAT = 10¶ R16G16B16A16_SINT = 14¶ R16G16B16A16_SNORM = 13¶ R16G16B16A16_TYPELESS = 9¶ R16G16B16A16_UINT = 12¶ R16G16B16A16_UNORM = 11¶ R16G16_FLOAT = 34¶ R16G16_SINT = 38¶ R16G16_SNORM = 37¶ R16G16_TYPELESS = 33¶ R16G16_UINT = 36¶ R16G16_UNORM = 35¶ R16_FLOAT = 54¶ R16_SINT = 59¶ R16_SNORM = 58¶ R16_TYPELESS = 53¶ R16_UINT = 57¶ R16_UNORM = 56¶ R1_UNORM = 66¶ R24G8_TYPELESS = 44¶ R24_UNORM_X8_TYPELESS = 46¶ R32G32B32A32_FLOAT = 2¶ R32G32B32A32_SINT = 4¶ R32G32B32A32_TYPELESS = 1¶ R32G32B32A32_UINT = 3¶ R32G32B32_FLOAT = 6¶ R32G32B32_SINT = 8¶ R32G32B32_TYPELESS = 5¶ R32G32B32_UINT = 7¶ R32G32_FLOAT = 16¶ R32G32_SINT = 18¶ R32G32_TYPELESS = 15¶ R32G32_UINT = 17¶ R32G8X24_TYPELESS = 19¶ R32_FLOAT = 41¶ R32_FLOAT_X8X24_TYPELESS = 21¶ R32_SINT = 43¶ R32_TYPELESS = 39¶ R32_UINT = 42¶ R8G8B8A8_SINT = 32¶ R8G8B8A8_SNORM = 31¶ R8G8B8A8_TYPELESS = 27¶ R8G8B8A8_UINT = 30¶ R8G8B8A8_UNORM = 28¶ R8G8B8A8_UNORM_SRGB = 29¶ R8G8_B8G8_UNORM = 68¶ R8G8_SINT = 52¶ R8G8_SNORM = 51¶ R8G8_TYPELESS = 48¶ R8G8_UINT = 50¶ R8G8_UNORM = 49¶ R8_SINT = 64¶ R8_SNORM = 63¶ R8_TYPELESS = 60¶ R8_UINT = 62¶ R8_UNORM = 61¶ R9G9B9E5_SHAREDEXP = 67¶ SAMPLER_FEEDBACK_MIN_MIP_OPAQUE = 189¶ SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE = 190¶ UNKNOWN = 0¶ V208 = 131¶ V408 = 132¶ X24_TYPELESS_G8_UINT = 47¶ X32_TYPELESS_G8X24_UINT = 22¶ Y210 = 108¶ Y216 = 109¶ Y410 = 101¶ Y416 = 102¶ YUY2 = 107¶ class PIL.DdsImagePlugin.DdsImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/DdsImagePlugin.html#DdsImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'DDS'¶ format_description = 'DirectDraw Surface'¶ load_seek(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/DdsImagePlugin.html#DdsImageFile.load_seek)¶ class PIL.DdsImagePlugin.DdsRgbDecoder(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _* args: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_)[[source]](../_modules/PIL/DdsImagePlugin.html#DdsRgbDecoder)¶ Bases: [`PyDecoder`](ImageFile.html#PIL.ImageFile.PyDecoder "PIL.ImageFile.PyDecoder") decode(_buffer : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [SupportsArrayInterface](Image.html#PIL.Image.SupportsArrayInterface "PIL.Image.SupportsArrayInterface")_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/DdsImagePlugin.html#DdsRgbDecoder.decode)¶ Override to perform the decoding process. Parameters: **buffer** – A bytes object with the data to be decoded. Returns: A tuple of `(bytes consumed, errcode)`. If finished with decoding return -1 for the bytes consumed. Err codes are from [`ImageFile.ERRORS`](ImageFile.html#PIL.ImageFile.ERRORS "PIL.ImageFile.ERRORS"). ## `EpsImagePlugin` module¶ class PIL.EpsImagePlugin.EpsImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/EpsImagePlugin.html#EpsImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") EPS File Parser for the Python Imaging Library format = 'EPS'¶ format_description = 'Encapsulated Postscript'¶ load(_scale : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 1_, _transparency : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = False_) -> [Image.core.PixelAccess](PixelAccess.html#PixelAccess "PIL.Image.core.PixelAccess") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/EpsImagePlugin.html#EpsImageFile.load)¶ Load image data based on tile list load_seek(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/EpsImagePlugin.html#EpsImageFile.load_seek)¶ mode_map = {1: 'L', 2: 'LAB', 3: 'RGB', 4: 'CMYK'}¶ PIL.EpsImagePlugin.Ghostscript(_tile : [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[ImageFile._Tile](ImageFile.html#PIL.ImageFile._Tile "PIL.ImageFile._Tile")]_, _size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _fp : IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _scale : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 1_, _transparency : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = False_) -> [Image.core.ImagingCore](internal_modules.html#PIL.Image.core.ImagingCore "PIL.Image.core.ImagingCore")[[source]](../_modules/PIL/EpsImagePlugin.html#Ghostscript)¶ Render an image using Ghostscript PIL.EpsImagePlugin.has_ghostscript() -> [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)")[[source]](../_modules/PIL/EpsImagePlugin.html#has_ghostscript)¶ ## `FitsImagePlugin` module¶ class PIL.FitsImagePlugin.FitsGzipDecoder(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _* args: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_)[[source]](../_modules/PIL/FitsImagePlugin.html#FitsGzipDecoder)¶ Bases: [`PyDecoder`](ImageFile.html#PIL.ImageFile.PyDecoder "PIL.ImageFile.PyDecoder") decode(_buffer : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [SupportsArrayInterface](Image.html#PIL.Image.SupportsArrayInterface "PIL.Image.SupportsArrayInterface")_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/FitsImagePlugin.html#FitsGzipDecoder.decode)¶ Override to perform the decoding process. Parameters: **buffer** – A bytes object with the data to be decoded. Returns: A tuple of `(bytes consumed, errcode)`. If finished with decoding return -1 for the bytes consumed. Err codes are from [`ImageFile.ERRORS`](ImageFile.html#PIL.ImageFile.ERRORS "PIL.ImageFile.ERRORS"). class PIL.FitsImagePlugin.FitsImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/FitsImagePlugin.html#FitsImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'FITS'¶ format_description = 'FITS'¶ ## `FliImagePlugin` module¶ class PIL.FliImagePlugin.FliImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/FliImagePlugin.html#FliImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'FLI'¶ format_description = 'Autodesk FLI/FLC Animation'¶ seek(_frame : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/FliImagePlugin.html#FliImageFile.seek)¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an `EOFError` exception. When a sequence file is opened, the library automatically seeks to frame 0. See [`tell()`](Image.html#PIL.Image.Image.tell "PIL.Image.Image.tell"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Parameters: **frame** – Frame number, starting at 0. Raises: [**EOFError**](https://docs.python.org/3/library/exceptions.html#EOFError "\(in Python v3.14\)") – If the call attempts to seek beyond the end of the sequence. tell() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/FliImagePlugin.html#FliImageFile.tell)¶ Returns the current frame number. See [`seek()`](Image.html#PIL.Image.Image.seek "PIL.Image.Image.seek"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Returns: Frame number, starting with 0. ## `FpxImagePlugin` module¶ class PIL.FpxImagePlugin.FpxImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/FpxImagePlugin.html#FpxImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") close() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/FpxImagePlugin.html#FpxImageFile.close)¶ Closes the file pointer, if possible. This operation will destroy the image core and release its memory. The image data will be unusable afterward. This function is required to close images that have multiple frames or have not had their file read and closed by the [`load()`](Image.html#PIL.Image.Image.load "PIL.Image.Image.load") method. See [File handling in Pillow](open_files.html#file-handling) for more information. format = 'FPX'¶ format_description = 'FlashPix'¶ load() -> [Image.core.PixelAccess](PixelAccess.html#PixelAccess "PIL.Image.core.PixelAccess") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/FpxImagePlugin.html#FpxImageFile.load)¶ Load image data based on tile list ## `GbrImagePlugin` module¶ class PIL.GbrImagePlugin.GbrImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/GbrImagePlugin.html#GbrImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'GBR'¶ format_description = 'GIMP brush file'¶ load() -> [Image.core.PixelAccess](PixelAccess.html#PixelAccess "PIL.Image.core.PixelAccess") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/GbrImagePlugin.html#GbrImageFile.load)¶ Load image data based on tile list ## `GifImagePlugin` module¶ class PIL.GifImagePlugin.GifImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/GifImagePlugin.html#GifImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") data() -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/GifImagePlugin.html#GifImageFile.data)¶ format = 'GIF'¶ format_description = 'Compuserve GIF'¶ global_palette = None¶ property is_animated: [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)")[[source]](../_modules/PIL/GifImagePlugin.html#GifImageFile.is_animated)¶ load_end() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/GifImagePlugin.html#GifImageFile.load_end)¶ load_prepare() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/GifImagePlugin.html#GifImageFile.load_prepare)¶ property n_frames: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ seek(_frame : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/GifImagePlugin.html#GifImageFile.seek)¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an `EOFError` exception. When a sequence file is opened, the library automatically seeks to frame 0. See [`tell()`](Image.html#PIL.Image.Image.tell "PIL.Image.Image.tell"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Parameters: **frame** – Frame number, starting at 0. Raises: [**EOFError**](https://docs.python.org/3/library/exceptions.html#EOFError "\(in Python v3.14\)") – If the call attempts to seek beyond the end of the sequence. tell() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/GifImagePlugin.html#GifImageFile.tell)¶ Returns the current frame number. See [`seek()`](Image.html#PIL.Image.Image.seek "PIL.Image.Image.seek"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Returns: Frame number, starting with 0. PIL.GifImagePlugin.LOADING_STRATEGY = LoadingStrategy.RGB_AFTER_FIRST¶ Added in version 9.1.0. class PIL.GifImagePlugin.LoadingStrategy(_* values_)[[source]](../_modules/PIL/GifImagePlugin.html#LoadingStrategy)¶ Bases: [`IntEnum`](https://docs.python.org/3/library/enum.html#enum.IntEnum "\(in Python v3.14\)") Added in version 9.1.0. RGB_AFTER_DIFFERENT_PALETTE_ONLY = 1¶ RGB_AFTER_FIRST = 0¶ RGB_ALWAYS = 2¶ PIL.GifImagePlugin.get_interlace(_im : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/GifImagePlugin.html#get_interlace)¶ PIL.GifImagePlugin.getdata(_im : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _offset : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] = (0, 0)_, _** params: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_) -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")][[source]](../_modules/PIL/GifImagePlugin.html#getdata)¶ Legacy Method Return a list of strings representing this image. The first string is a local image header, the rest contains encoded image data. To specify duration, add the time in milliseconds, e.g. `getdata(im_frame, duration=1000)` Parameters: * **im** – Image object * **offset** – Tuple of (x, y) pixels. Defaults to (0, 0) * ****params** – e.g. duration or other encoder info parameters Returns: List of bytes containing GIF encoded frame data PIL.GifImagePlugin.getheader(_im : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _palette : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [bytearray](https://docs.python.org/3/library/stdtypes.html#bytearray "\(in Python v3.14\)") | [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [ImagePalette](ImagePalette.html#PIL.ImagePalette.ImagePalette "PIL.ImagePalette.ImagePalette") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _info : [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")], [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")][[source]](../_modules/PIL/GifImagePlugin.html#getheader)¶ Legacy Method to get Gif data from image. Warning:: May modify image data. Parameters: * **im** – Image object * **palette** – bytes object containing the source palette, or …. * **info** – encoderinfo Returns: tuple of(list of header items, optimized palette) ## `GribStubImagePlugin` module¶ class PIL.GribStubImagePlugin.GribStubImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/GribStubImagePlugin.html#GribStubImageFile)¶ Bases: [`StubImageFile`](ImageFile.html#PIL.ImageFile.StubImageFile "PIL.ImageFile.StubImageFile") format = 'GRIB'¶ format_description = 'GRIB'¶ PIL.GribStubImagePlugin.register_handler(_handler : [StubHandler](ImageFile.html#PIL.ImageFile.StubHandler "PIL.ImageFile.StubHandler") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/GribStubImagePlugin.html#register_handler)¶ Install application-specific GRIB image handler. Parameters: **handler** – Handler object. ## `Hdf5StubImagePlugin` module¶ class PIL.Hdf5StubImagePlugin.HDF5StubImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/Hdf5StubImagePlugin.html#HDF5StubImageFile)¶ Bases: [`StubImageFile`](ImageFile.html#PIL.ImageFile.StubImageFile "PIL.ImageFile.StubImageFile") format = 'HDF5'¶ format_description = 'HDF5'¶ PIL.Hdf5StubImagePlugin.register_handler(_handler : [StubHandler](ImageFile.html#PIL.ImageFile.StubHandler "PIL.ImageFile.StubHandler") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Hdf5StubImagePlugin.html#register_handler)¶ Install application-specific HDF5 image handler. Parameters: **handler** – Handler object. ## `IcnsImagePlugin` module¶ class PIL.IcnsImagePlugin.IcnsFile(_fobj : [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_)[[source]](../_modules/PIL/IcnsImagePlugin.html#IcnsFile)¶ Bases: [`object`](https://docs.python.org/3/library/functions.html#object "\(in Python v3.14\)") SIZES = {(16, 16, 1): [(b'icp4', ), (b'is32', ), (b's8mk', )], (16, 16, 2): [(b'ic11', )], (32, 32, 1): [(b'icp5', ), (b'il32', ), (b'l8mk', )], (32, 32, 2): [(b'ic12', )], (48, 48, 1): [(b'ih32', ), (b'h8mk', )], (64, 64, 1): [(b'icp6', )], (128, 128, 1): [(b'ic07', ), (b'it32', ), (b't8mk', )], (128, 128, 2): [(b'ic13', )], (256, 256, 1): [(b'ic08', )], (256, 256, 2): [(b'ic14', )], (512, 512, 1): [(b'ic09', )], (512, 512, 2): [(b'ic10', )]}¶ bestsize() -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/IcnsImagePlugin.html#IcnsFile.bestsize)¶ dataforsize(_size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_) -> [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), [Image](Image.html#PIL.Image.Image "PIL.Image.Image")][[source]](../_modules/PIL/IcnsImagePlugin.html#IcnsFile.dataforsize)¶ Get an icon resource as {channel: array}. Note that the arrays are bottom-up like windows bitmaps and will likely need to be flipped or transposed in some way. getimage(_size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/IcnsImagePlugin.html#IcnsFile.getimage)¶ itersizes() -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]][[source]](../_modules/PIL/IcnsImagePlugin.html#IcnsFile.itersizes)¶ class PIL.IcnsImagePlugin.IcnsImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/IcnsImagePlugin.html#IcnsImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") PIL image support for Mac OS .icns files. Chooses the best resolution, but will possibly load a different size image if you mutate the size attribute before calling ‘load’. The info dictionary has a key ‘sizes’ that is a list of sizes that the icns file has. format = 'ICNS'¶ format_description = 'Mac OS icns resource'¶ load(_scale : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [Image.core.PixelAccess](PixelAccess.html#PixelAccess "PIL.Image.core.PixelAccess") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/IcnsImagePlugin.html#IcnsImageFile.load)¶ Load image data based on tile list property size: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]¶ PIL.IcnsImagePlugin.nextheader(_fobj : [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/IcnsImagePlugin.html#nextheader)¶ PIL.IcnsImagePlugin.read_32(_fobj : [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _start_length : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_) -> [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), [Image](Image.html#PIL.Image.Image "PIL.Image.Image")][[source]](../_modules/PIL/IcnsImagePlugin.html#read_32)¶ Read a 32bit RGB icon resource. Seems to be either uncompressed or an RLE packbits-like scheme. PIL.IcnsImagePlugin.read_32t(_fobj : [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _start_length : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_) -> [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), [Image](Image.html#PIL.Image.Image "PIL.Image.Image")][[source]](../_modules/PIL/IcnsImagePlugin.html#read_32t)¶ PIL.IcnsImagePlugin.read_mk(_fobj : [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _start_length : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_) -> [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), [Image](Image.html#PIL.Image.Image "PIL.Image.Image")][[source]](../_modules/PIL/IcnsImagePlugin.html#read_mk)¶ PIL.IcnsImagePlugin.read_png_or_jpeg2000(_fobj : [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _start_length : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_) -> [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), [Image](Image.html#PIL.Image.Image "PIL.Image.Image")][[source]](../_modules/PIL/IcnsImagePlugin.html#read_png_or_jpeg2000)¶ ## `IcoImagePlugin` module¶ class PIL.IcoImagePlugin.IcoFile(_buf : [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_)[[source]](../_modules/PIL/IcoImagePlugin.html#IcoFile)¶ Bases: [`object`](https://docs.python.org/3/library/functions.html#object "\(in Python v3.14\)") frame(_idx : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/IcoImagePlugin.html#IcoFile.frame)¶ Get an image from frame idx getentryindex(_size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _bpp : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = False_) -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/IcoImagePlugin.html#IcoFile.getentryindex)¶ getimage(_size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_, _bpp : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = False_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/IcoImagePlugin.html#IcoFile.getimage)¶ Get an image from the icon sizes() -> [set](https://docs.python.org/3/library/stdtypes.html#set "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]][[source]](../_modules/PIL/IcoImagePlugin.html#IcoFile.sizes)¶ Get a set of all available icon sizes and color depths. class PIL.IcoImagePlugin.IcoImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/IcoImagePlugin.html#IcoImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") PIL read-only image support for Microsoft Windows .ico files. By default the largest resolution image in the file will be loaded. This can be changed by altering the ‘size’ attribute before calling ‘load’. The info dictionary has a key ‘sizes’ that is a list of the sizes available in the icon file. Handles classic, XP and Vista icon formats. When saving, PNG compression is used. Support for this was only added in Windows Vista. If you are unable to view the icon in Windows, convert the image to “RGBA” mode before saving. This plugin is a refactored version of Win32IconImagePlugin by Bryan Davis <[casadebender@gmail.com](mailto:casadebender%40gmail.com)>. format = 'ICO'¶ format_description = 'Windows Icon'¶ load() -> [Image.core.PixelAccess](PixelAccess.html#PixelAccess "PIL.Image.core.PixelAccess") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/IcoImagePlugin.html#IcoImageFile.load)¶ Load image data based on tile list load_seek(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/IcoImagePlugin.html#IcoImageFile.load_seek)¶ property size: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]¶ class PIL.IcoImagePlugin.IconHeader(_width_ , _height_ , _nb_color_ , _reserved_ , _planes_ , _bpp_ , _size_ , _offset_ , _dim_ , _square_ , _color_depth_)[[source]](../_modules/PIL/IcoImagePlugin.html#IconHeader)¶ Bases: [`NamedTuple`](https://docs.python.org/3/library/typing.html#typing.NamedTuple "\(in Python v3.14\)") bpp: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ Alias for field number 5 color_depth: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ Alias for field number 10 dim: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]¶ Alias for field number 8 height: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ Alias for field number 1 nb_color: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ Alias for field number 2 offset: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ Alias for field number 7 planes: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ Alias for field number 4 reserved: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ Alias for field number 3 size: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ Alias for field number 6 square: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ Alias for field number 9 width: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ Alias for field number 0 ## `ImImagePlugin` module¶ class PIL.ImImagePlugin.ImImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/ImImagePlugin.html#ImImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'IM'¶ format_description = 'IFUNC Image Memory'¶ property is_animated: [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)")¶ property n_frames: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ seek(_frame : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/ImImagePlugin.html#ImImageFile.seek)¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an `EOFError` exception. When a sequence file is opened, the library automatically seeks to frame 0. See [`tell()`](Image.html#PIL.Image.Image.tell "PIL.Image.Image.tell"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Parameters: **frame** – Frame number, starting at 0. Raises: [**EOFError**](https://docs.python.org/3/library/exceptions.html#EOFError "\(in Python v3.14\)") – If the call attempts to seek beyond the end of the sequence. tell() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/ImImagePlugin.html#ImImageFile.tell)¶ Returns the current frame number. See [`seek()`](Image.html#PIL.Image.Image.seek "PIL.Image.Image.seek"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Returns: Frame number, starting with 0. PIL.ImImagePlugin.number(_s : [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_) -> [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")[[source]](../_modules/PIL/ImImagePlugin.html#number)¶ ## `ImtImagePlugin` module¶ class PIL.ImtImagePlugin.ImtImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/ImtImagePlugin.html#ImtImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'IMT'¶ format_description = 'IM Tools'¶ ## `IptcImagePlugin` module¶ class PIL.IptcImagePlugin.IptcImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/IptcImagePlugin.html#IptcImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") field() -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/IptcImagePlugin.html#IptcImageFile.field)¶ format = 'IPTC'¶ format_description = 'IPTC/NAA'¶ getint(_key : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]_) -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/IptcImagePlugin.html#IptcImageFile.getint)¶ load() -> [Image.core.PixelAccess](PixelAccess.html#PixelAccess "PIL.Image.core.PixelAccess") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/IptcImagePlugin.html#IptcImageFile.load)¶ Load image data based on tile list PIL.IptcImagePlugin.getiptcinfo(_im : [ImageFile](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile")_) -> [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")], [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/IptcImagePlugin.html#getiptcinfo)¶ Get IPTC information from TIFF, JPEG, or IPTC file. Parameters: **im** – An image containing IPTC data. Returns: A dictionary containing IPTC information, or None if no IPTC information block was found. ## `JpegImagePlugin` module¶ PIL.JpegImagePlugin.APP(_self : JpegImageFile_, _marker : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/JpegImagePlugin.html#APP)¶ PIL.JpegImagePlugin.COM(_self : JpegImageFile_, _marker : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/JpegImagePlugin.html#COM)¶ PIL.JpegImagePlugin.DQT(_self : JpegImageFile_, _marker : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/JpegImagePlugin.html#DQT)¶ class PIL.JpegImagePlugin.JpegImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/JpegImagePlugin.html#JpegImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") draft(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")_, _size : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/JpegImagePlugin.html#JpegImageFile.draft)¶ Configures the image file loader so it returns a version of the image that as closely as possible matches the given mode and size. For example, you can use this method to convert a color JPEG to grayscale while loading it. If any changes are made, returns a tuple with the chosen `mode` and `box` with coordinates of the original image within the altered one. Note that this method modifies the [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") object in place. If the image has already been loaded, this method has no effect. Note: This method is not implemented for most images. It is currently implemented only for JPEG and MPO images. Parameters: * **mode** – The requested mode. * **size** – The requested size in pixels, as a 2-tuple: (width, height). format = 'JPEG'¶ format_description = 'JPEG (ISO 10918)'¶ load_djpeg() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/JpegImagePlugin.html#JpegImageFile.load_djpeg)¶ load_read(_read_bytes : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/JpegImagePlugin.html#JpegImageFile.load_read)¶ internal: read more image data For premature EOF and LOAD_TRUNCATED_IMAGES adds EOI marker so libjpeg can finish decoding PIL.JpegImagePlugin.SOF(_self : JpegImageFile_, _marker : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/JpegImagePlugin.html#SOF)¶ PIL.JpegImagePlugin.Skip(_self : JpegImageFile_, _marker : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/JpegImagePlugin.html#Skip)¶ PIL.JpegImagePlugin.get_sampling(_im : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/JpegImagePlugin.html#get_sampling)¶ PIL.JpegImagePlugin.jpeg_factory(_fp : IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> JpegImageFile | MpoImageFile[[source]](../_modules/PIL/JpegImagePlugin.html#jpeg_factory)¶ ## `Jpeg2KImagePlugin` module¶ class PIL.Jpeg2KImagePlugin.BoxReader(_fp : IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = -1_)[[source]](../_modules/PIL/Jpeg2KImagePlugin.html#BoxReader)¶ Bases: [`object`](https://docs.python.org/3/library/functions.html#object "\(in Python v3.14\)") A small helper class to read fields stored in JPEG2000 header boxes and to easily step into and read sub-boxes. has_next_box() -> [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)")[[source]](../_modules/PIL/Jpeg2KImagePlugin.html#BoxReader.has_next_box)¶ next_box_type() -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/Jpeg2KImagePlugin.html#BoxReader.next_box_type)¶ read_boxes() -> BoxReader[[source]](../_modules/PIL/Jpeg2KImagePlugin.html#BoxReader.read_boxes)¶ read_fields(_field_format : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)"), ...][[source]](../_modules/PIL/Jpeg2KImagePlugin.html#BoxReader.read_fields)¶ class PIL.Jpeg2KImagePlugin.Jpeg2KImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/Jpeg2KImagePlugin.html#Jpeg2KImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'JPEG2000'¶ format_description = 'JPEG 2000 (ISO 15444)'¶ load() -> [Image.core.PixelAccess](PixelAccess.html#PixelAccess "PIL.Image.core.PixelAccess") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/Jpeg2KImagePlugin.html#Jpeg2KImageFile.load)¶ Load image data based on tile list property reduce: Callable[[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")], [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")], [Image.Image](Image.html#PIL.Image.Image "PIL.Image.Image")] | [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ Returns a copy of the image reduced `factor` times. If the size of the image is not dividable by `factor`, the resulting size will be rounded up. Parameters: * **factor** – A greater than 0 integer or tuple of two integers for width and height separately. * **box** – An optional 4-tuple of ints providing the source image region to be reduced. The values must be within `(0, 0, width, height)` rectangle. If omitted or `None`, the entire source is used. ## `McIdasImagePlugin` module¶ class PIL.McIdasImagePlugin.McIdasImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/McIdasImagePlugin.html#McIdasImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'MCIDAS'¶ format_description = 'McIdas area file'¶ ## `MicImagePlugin` module¶ class PIL.MicImagePlugin.MicImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/MicImagePlugin.html#MicImageFile)¶ Bases: `TiffImageFile` close() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/MicImagePlugin.html#MicImageFile.close)¶ Closes the file pointer, if possible. This operation will destroy the image core and release its memory. The image data will be unusable afterward. This function is required to close images that have multiple frames or have not had their file read and closed by the [`load()`](Image.html#PIL.Image.Image.load "PIL.Image.Image.load") method. See [File handling in Pillow](open_files.html#file-handling) for more information. format = 'MIC'¶ format_description = 'Microsoft Image Composer'¶ seek(_frame : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/MicImagePlugin.html#MicImageFile.seek)¶ Select a given frame as current image tell() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/MicImagePlugin.html#MicImageFile.tell)¶ Return the current frame number ## `MpegImagePlugin` module¶ class PIL.MpegImagePlugin.BitStream(_fp : [SupportsRead](internal_modules.html#PIL._typing.SupportsRead "PIL._typing.SupportsRead")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_)[[source]](../_modules/PIL/MpegImagePlugin.html#BitStream)¶ Bases: [`object`](https://docs.python.org/3/library/functions.html#object "\(in Python v3.14\)") next() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/MpegImagePlugin.html#BitStream.next)¶ peek(_bits : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/MpegImagePlugin.html#BitStream.peek)¶ read(_bits : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/MpegImagePlugin.html#BitStream.read)¶ skip(_bits : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/MpegImagePlugin.html#BitStream.skip)¶ class PIL.MpegImagePlugin.MpegImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/MpegImagePlugin.html#MpegImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'MPEG'¶ format_description = 'MPEG'¶ ## `MpoImagePlugin` module¶ class PIL.MpoImagePlugin.MpoImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/MpoImagePlugin.html#MpoImageFile)¶ Bases: `JpegImageFile` static adopt(_jpeg_instance : JpegImageFile_, _mpheader : [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> MpoImageFile[[source]](../_modules/PIL/MpoImagePlugin.html#MpoImageFile.adopt)¶ Transform the instance of JpegImageFile into an instance of MpoImageFile. After the call, the JpegImageFile is extended to be an MpoImageFile. This is essentially useful when opening a JPEG file that reveals itself as an MPO, to avoid double call to _open. format = 'MPO'¶ format_description = 'MPO (CIPA DC-007)'¶ load_seek(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/MpoImagePlugin.html#MpoImageFile.load_seek)¶ seek(_frame : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/MpoImagePlugin.html#MpoImageFile.seek)¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an `EOFError` exception. When a sequence file is opened, the library automatically seeks to frame 0. See [`tell()`](Image.html#PIL.Image.Image.tell "PIL.Image.Image.tell"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Parameters: **frame** – Frame number, starting at 0. Raises: [**EOFError**](https://docs.python.org/3/library/exceptions.html#EOFError "\(in Python v3.14\)") – If the call attempts to seek beyond the end of the sequence. tell() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/MpoImagePlugin.html#MpoImageFile.tell)¶ Returns the current frame number. See [`seek()`](Image.html#PIL.Image.Image.seek "PIL.Image.Image.seek"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Returns: Frame number, starting with 0. ## `MspImagePlugin` module¶ class PIL.MspImagePlugin.MspDecoder(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _* args: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_)[[source]](../_modules/PIL/MspImagePlugin.html#MspDecoder)¶ Bases: [`PyDecoder`](ImageFile.html#PIL.ImageFile.PyDecoder "PIL.ImageFile.PyDecoder") decode(_buffer : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [SupportsArrayInterface](Image.html#PIL.Image.SupportsArrayInterface "PIL.Image.SupportsArrayInterface")_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/MspImagePlugin.html#MspDecoder.decode)¶ Override to perform the decoding process. Parameters: **buffer** – A bytes object with the data to be decoded. Returns: A tuple of `(bytes consumed, errcode)`. If finished with decoding return -1 for the bytes consumed. Err codes are from [`ImageFile.ERRORS`](ImageFile.html#PIL.ImageFile.ERRORS "PIL.ImageFile.ERRORS"). class PIL.MspImagePlugin.MspImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/MspImagePlugin.html#MspImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'MSP'¶ format_description = 'Windows Paint'¶ ## `PalmImagePlugin` module¶ PIL.PalmImagePlugin.build_prototype_image() -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/PalmImagePlugin.html#build_prototype_image)¶ ## `PcdImagePlugin` module¶ class PIL.PcdImagePlugin.PcdImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/PcdImagePlugin.html#PcdImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'PCD'¶ format_description = 'Kodak PhotoCD'¶ load_end() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PcdImagePlugin.html#PcdImageFile.load_end)¶ load_prepare() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PcdImagePlugin.html#PcdImageFile.load_prepare)¶ ## `PcxImagePlugin` module¶ class PIL.PcxImagePlugin.PcxImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/PcxImagePlugin.html#PcxImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'PCX'¶ format_description = 'Paintbrush'¶ ## `PdfImagePlugin` module¶ ## `PixarImagePlugin` module¶ class PIL.PixarImagePlugin.PixarImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/PixarImagePlugin.html#PixarImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'PIXAR'¶ format_description = 'PIXAR raster image'¶ ## `PngImagePlugin` module¶ class PIL.PngImagePlugin.Blend(_* values_)[[source]](../_modules/PIL/PngImagePlugin.html#Blend)¶ Bases: [`IntEnum`](https://docs.python.org/3/library/enum.html#enum.IntEnum "\(in Python v3.14\)") OP_OVER = 1¶ This frame should be alpha composited with the previous output image contents. See [Saving APNG sequences](../handbook/image-file-formats.html#apng-saving). OP_SOURCE = 0¶ All color components of this frame, including alpha, overwrite the previous output image contents. See [Saving APNG sequences](../handbook/image-file- formats.html#apng-saving). class PIL.PngImagePlugin.ChunkStream(_fp : [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_)[[source]](../_modules/PIL/PngImagePlugin.html#ChunkStream)¶ Bases: [`object`](https://docs.python.org/3/library/functions.html#object "\(in Python v3.14\)") call(_cid : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#ChunkStream.call)¶ Call the appropriate chunk handler close() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#ChunkStream.close)¶ crc(_cid : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#ChunkStream.crc)¶ Read and verify checksum crc_skip(_cid : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#ChunkStream.crc_skip)¶ Read checksum push(_cid : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#ChunkStream.push)¶ read() -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/PngImagePlugin.html#ChunkStream.read)¶ Fetch a new chunk. Returns header information. verify(_endchunk : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") = b'IEND'_) -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")][[source]](../_modules/PIL/PngImagePlugin.html#ChunkStream.verify)¶ fp: [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ queue: [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ class PIL.PngImagePlugin.Disposal(_* values_)[[source]](../_modules/PIL/PngImagePlugin.html#Disposal)¶ Bases: [`IntEnum`](https://docs.python.org/3/library/enum.html#enum.IntEnum "\(in Python v3.14\)") OP_BACKGROUND = 1¶ This frame’s modified region is cleared to fully transparent black before rendering the next frame. See [Saving APNG sequences](../handbook/image-file- formats.html#apng-saving). OP_NONE = 0¶ No disposal is done on this frame before rendering the next frame. See [Saving APNG sequences](../handbook/image-file-formats.html#apng-saving). OP_PREVIOUS = 2¶ This frame’s modified region is reverted to the previous frame’s contents before rendering the next frame. See [Saving APNG sequences](../handbook/image-file-formats.html#apng-saving). class PIL.PngImagePlugin.PngImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/PngImagePlugin.html#PngImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") getexif() -> [Exif](Image.html#PIL.Image.Exif "PIL.Image.Exif")[[source]](../_modules/PIL/PngImagePlugin.html#PngImageFile.getexif)¶ Gets EXIF data from the image. Returns: an [`Exif`](Image.html#PIL.Image.Exif "PIL.Image.Exif") object. load_end() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngImageFile.load_end)¶ internal: finished reading image data load_prepare() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngImageFile.load_prepare)¶ internal: prepare to read PNG file load_read(_read_bytes : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngImageFile.load_read)¶ internal: read more image data seek(_frame : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngImageFile.seek)¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an `EOFError` exception. When a sequence file is opened, the library automatically seeks to frame 0. See [`tell()`](Image.html#PIL.Image.Image.tell "PIL.Image.Image.tell"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Parameters: **frame** – Frame number, starting at 0. Raises: [**EOFError**](https://docs.python.org/3/library/exceptions.html#EOFError "\(in Python v3.14\)") – If the call attempts to seek beyond the end of the sequence. tell() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngImageFile.tell)¶ Returns the current frame number. See [`seek()`](Image.html#PIL.Image.Image.seek "PIL.Image.Image.seek"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Returns: Frame number, starting with 0. verify() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngImageFile.verify)¶ Verify PNG file format = 'PNG'¶ format_description = 'Portable network graphics'¶ property text: [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [iTXt](../PIL.html#PIL.PngImagePlugin.iTXt "PIL.PngImagePlugin.iTXt")]¶ class PIL.PngImagePlugin.PngStream(_fp : [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_)[[source]](../_modules/PIL/PngImagePlugin.html#PngStream)¶ Bases: `ChunkStream` check_text_memory(_chunklen : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.check_text_memory)¶ chunk_IDAT(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> NoReturn[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.chunk_IDAT)¶ chunk_IEND(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> NoReturn[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.chunk_IEND)¶ chunk_IHDR(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.chunk_IHDR)¶ chunk_PLTE(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.chunk_PLTE)¶ chunk_acTL(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.chunk_acTL)¶ chunk_cHRM(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.chunk_cHRM)¶ chunk_eXIf(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.chunk_eXIf)¶ chunk_fcTL(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.chunk_fcTL)¶ chunk_fdAT(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.chunk_fdAT)¶ chunk_gAMA(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.chunk_gAMA)¶ chunk_iCCP(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.chunk_iCCP)¶ chunk_iTXt(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.chunk_iTXt)¶ chunk_pHYs(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.chunk_pHYs)¶ chunk_sRGB(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.chunk_sRGB)¶ chunk_tEXt(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.chunk_tEXt)¶ chunk_tRNS(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.chunk_tRNS)¶ chunk_zTXt(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _length : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.chunk_zTXt)¶ rewind() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.rewind)¶ save_rewind() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#PngStream.save_rewind)¶ im_custom_mimetype: [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ im_info: [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")], Any]¶ im_n_frames: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ im_palette: [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")¶ im_text: [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [iTXt](../PIL.html#PIL.PngImagePlugin.iTXt "PIL.PngImagePlugin.iTXt")]¶ im_tile: [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[ImageFile._Tile](ImageFile.html#PIL.ImageFile._Tile "PIL.ImageFile._Tile")]¶ PIL.PngImagePlugin.getchunks(_im : [Image.Image](Image.html#PIL.Image.Image "PIL.Image.Image")_, _** params: Any_) -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)"), [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)"), [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]][[source]](../_modules/PIL/PngImagePlugin.html#getchunks)¶ Return a list of PNG chunks representing this image. PIL.PngImagePlugin.is_cid(_string_ , _pos =0_, _endpos =9223372036854775807_)¶ Matches zero or more characters at the beginning of the string. PIL.PngImagePlugin.putchunk(_fp : [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _cid : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _* data: [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PngImagePlugin.html#putchunk)¶ Write a PNG chunk (including CRC field) PIL.PngImagePlugin.MAX_TEXT_CHUNK = 1048576¶ Maximum decompressed size for a iTXt or zTXt chunk. Eliminates decompression bombs where compressed chunks can expand 1000x. See [Text in PNG File Format](../handbook/image-file-formats.html#png-text). PIL.PngImagePlugin.MAX_TEXT_MEMORY = 67108864¶ Set the maximum total text chunk size. See [Text in PNG File Format](../handbook/image-file-formats.html#png-text). ## `PpmImagePlugin` module¶ class PIL.PpmImagePlugin.PpmDecoder(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _* args: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_)[[source]](../_modules/PIL/PpmImagePlugin.html#PpmDecoder)¶ Bases: [`PyDecoder`](ImageFile.html#PIL.ImageFile.PyDecoder "PIL.ImageFile.PyDecoder") decode(_buffer : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [SupportsArrayInterface](Image.html#PIL.Image.SupportsArrayInterface "PIL.Image.SupportsArrayInterface")_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/PpmImagePlugin.html#PpmDecoder.decode)¶ Override to perform the decoding process. Parameters: **buffer** – A bytes object with the data to be decoded. Returns: A tuple of `(bytes consumed, errcode)`. If finished with decoding return -1 for the bytes consumed. Err codes are from [`ImageFile.ERRORS`](ImageFile.html#PIL.ImageFile.ERRORS "PIL.ImageFile.ERRORS"). class PIL.PpmImagePlugin.PpmImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/PpmImagePlugin.html#PpmImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'PPM'¶ format_description = 'Pbmplus image'¶ class PIL.PpmImagePlugin.PpmPlainDecoder(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _* args: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_)[[source]](../_modules/PIL/PpmImagePlugin.html#PpmPlainDecoder)¶ Bases: [`PyDecoder`](ImageFile.html#PIL.ImageFile.PyDecoder "PIL.ImageFile.PyDecoder") decode(_buffer : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [SupportsArrayInterface](Image.html#PIL.Image.SupportsArrayInterface "PIL.Image.SupportsArrayInterface")_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/PpmImagePlugin.html#PpmPlainDecoder.decode)¶ Override to perform the decoding process. Parameters: **buffer** – A bytes object with the data to be decoded. Returns: A tuple of `(bytes consumed, errcode)`. If finished with decoding return -1 for the bytes consumed. Err codes are from [`ImageFile.ERRORS`](ImageFile.html#PIL.ImageFile.ERRORS "PIL.ImageFile.ERRORS"). ## `PsdImagePlugin` module¶ class PIL.PsdImagePlugin.PsdImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/PsdImagePlugin.html#PsdImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'PSD'¶ format_description = 'Adobe Photoshop'¶ property is_animated: [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)")¶ property layers: [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")], [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[_Tile](ImageFile.html#PIL.ImageFile._Tile "PIL.ImageFile._Tile")]]][[source]](../_modules/PIL/PsdImagePlugin.html#PsdImageFile.layers)¶ property n_frames: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ seek(_layer : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/PsdImagePlugin.html#PsdImageFile.seek)¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an `EOFError` exception. When a sequence file is opened, the library automatically seeks to frame 0. See [`tell()`](Image.html#PIL.Image.Image.tell "PIL.Image.Image.tell"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Parameters: **frame** – Frame number, starting at 0. Raises: [**EOFError**](https://docs.python.org/3/library/exceptions.html#EOFError "\(in Python v3.14\)") – If the call attempts to seek beyond the end of the sequence. tell() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/PsdImagePlugin.html#PsdImageFile.tell)¶ Returns the current frame number. See [`seek()`](Image.html#PIL.Image.Image.seek "PIL.Image.Image.seek"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Returns: Frame number, starting with 0. ## `SgiImagePlugin` module¶ class PIL.SgiImagePlugin.SGI16Decoder(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _* args: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_)[[source]](../_modules/PIL/SgiImagePlugin.html#SGI16Decoder)¶ Bases: [`PyDecoder`](ImageFile.html#PIL.ImageFile.PyDecoder "PIL.ImageFile.PyDecoder") decode(_buffer : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [SupportsArrayInterface](Image.html#PIL.Image.SupportsArrayInterface "PIL.Image.SupportsArrayInterface")_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/SgiImagePlugin.html#SGI16Decoder.decode)¶ Override to perform the decoding process. Parameters: **buffer** – A bytes object with the data to be decoded. Returns: A tuple of `(bytes consumed, errcode)`. If finished with decoding return -1 for the bytes consumed. Err codes are from [`ImageFile.ERRORS`](ImageFile.html#PIL.ImageFile.ERRORS "PIL.ImageFile.ERRORS"). class PIL.SgiImagePlugin.SgiImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/SgiImagePlugin.html#SgiImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'SGI'¶ format_description = 'SGI Image File Format'¶ ## `SpiderImagePlugin` module¶ class PIL.SpiderImagePlugin.SpiderImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/SpiderImagePlugin.html#SpiderImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") convert2byte(_depth : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 255_) -> [Image](Image.html#PIL.Image.Image "PIL.Image.Image")[[source]](../_modules/PIL/SpiderImagePlugin.html#SpiderImageFile.convert2byte)¶ format = 'SPIDER'¶ format_description = 'Spider 2D image'¶ property is_animated: [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)")¶ property n_frames: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ seek(_frame : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/SpiderImagePlugin.html#SpiderImageFile.seek)¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an `EOFError` exception. When a sequence file is opened, the library automatically seeks to frame 0. See [`tell()`](Image.html#PIL.Image.Image.tell "PIL.Image.Image.tell"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Parameters: **frame** – Frame number, starting at 0. Raises: [**EOFError**](https://docs.python.org/3/library/exceptions.html#EOFError "\(in Python v3.14\)") – If the call attempts to seek beyond the end of the sequence. tell() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/SpiderImagePlugin.html#SpiderImageFile.tell)¶ Returns the current frame number. See [`seek()`](Image.html#PIL.Image.Image.seek "PIL.Image.Image.seek"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Returns: Frame number, starting with 0. tkPhotoImage() -> [ImageTk.PhotoImage](ImageTk.html#PIL.ImageTk.PhotoImage "PIL.ImageTk.PhotoImage")[[source]](../_modules/PIL/SpiderImagePlugin.html#SpiderImageFile.tkPhotoImage)¶ PIL.SpiderImagePlugin.isInt(_f : [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_) -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/SpiderImagePlugin.html#isInt)¶ PIL.SpiderImagePlugin.isSpiderHeader(_t : [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), ...]_) -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/SpiderImagePlugin.html#isSpiderHeader)¶ PIL.SpiderImagePlugin.isSpiderImage(_filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/SpiderImagePlugin.html#isSpiderImage)¶ PIL.SpiderImagePlugin.loadImageSeries(_filelist : [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[Image](Image.html#PIL.Image.Image "PIL.Image.Image")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/SpiderImagePlugin.html#loadImageSeries)¶ create a list of [`Image`](Image.html#PIL.Image.Image "PIL.Image.Image") objects for use in a montage PIL.SpiderImagePlugin.makeSpiderHeader(_im : [Image](Image.html#PIL.Image.Image "PIL.Image.Image")_) -> [list](https://docs.python.org/3/library/stdtypes.html#list "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")][[source]](../_modules/PIL/SpiderImagePlugin.html#makeSpiderHeader)¶ ## `SunImagePlugin` module¶ class PIL.SunImagePlugin.SunImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/SunImagePlugin.html#SunImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'SUN'¶ format_description = 'Sun Raster File'¶ ## `TgaImagePlugin` module¶ class PIL.TgaImagePlugin.TgaImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/TgaImagePlugin.html#TgaImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'TGA'¶ format_description = 'Targa'¶ load_end() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TgaImagePlugin.html#TgaImageFile.load_end)¶ ## `TiffImagePlugin` module¶ class PIL.TiffImagePlugin.AppendingTiffWriter(_fn : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _new : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = False_)[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter)¶ Bases: [`BytesIO`](https://docs.python.org/3/library/io.html#io.BytesIO "\(in Python v3.14\)") Tags = {273, 288, 324, 519, 520, 521}¶ close() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.close)¶ Disable all I/O operations. f: [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]¶ fieldSizes = [0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 4, 2, 4, 8]¶ finalize() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.finalize)¶ fixIFD() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.fixIFD)¶ fixOffsets(_count : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _isShort : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = False_, _isLong : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = False_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.fixOffsets)¶ goToEnd() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.goToEnd)¶ newFrame() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.newFrame)¶ readLong() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.readLong)¶ readShort() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.readShort)¶ rewriteLastLong(_value : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.rewriteLastLong)¶ rewriteLastShort(_value : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.rewriteLastShort)¶ rewriteLastShortToLong(_value : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.rewriteLastShortToLong)¶ seek(_offset : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_, _whence : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 0_) -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.seek)¶ Parameters: * **offset** – Distance to seek. * **whence** – Whether the distance is relative to the start, end or current position. Returns: The resulting position, relative to the start. setEndian(_endian : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.setEndian)¶ setup() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.setup)¶ skipIFDs() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.skipIFDs)¶ tell() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.tell)¶ Current file position, an integer. write(_data : [Buffer](internal_modules.html#PIL._typing.Buffer "PIL._typing.Buffer")_, _/_) -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.write)¶ Write bytes to file. Return the number of bytes written. writeLong(_value : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.writeLong)¶ writeShort(_value : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#AppendingTiffWriter.writeShort)¶ class PIL.TiffImagePlugin.IFDRational(_value : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [Fraction](https://docs.python.org/3/library/fractions.html#fractions.Fraction "\(in Python v3.14\)") | IFDRational_, _denominator : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 1_)[[source]](../_modules/PIL/TiffImagePlugin.html#IFDRational)¶ Bases: [`Rational`](https://docs.python.org/3/library/numbers.html#numbers.Rational "\(in Python v3.14\)") Implements a rational class where 0/0 is a legal value to match the in the wild use of exif rationals. e.g., DigitalZoomRatio - 0.00/0.00 indicates that no digital zoom was used property denominator: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ limit_rational(_max_denominator : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[IntegralLike](internal_modules.html#PIL._typing.IntegralLike "PIL._typing.IntegralLike"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/TiffImagePlugin.html#IFDRational.limit_rational)¶ Parameters: **max_denominator** – Integer, the maximum denominator value Returns: Tuple of (numerator, denominator) property numerator: [IntegralLike](internal_modules.html#PIL._typing.IntegralLike "PIL._typing.IntegralLike")¶ PIL.TiffImagePlugin.ImageFileDirectory¶ alias of `ImageFileDirectory_v1` class PIL.TiffImagePlugin.ImageFileDirectory_v1(_* args: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_, _** kwargs: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_)[[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v1)¶ Bases: `ImageFileDirectory_v2` This class represents the **legacy** interface to a TIFF tag directory. Exposes a dictionary interface of the tags in the directory: ifd = ImageFileDirectory_v1() ifd[key] = 'Some Data' ifd.tagtype[key] = TiffTags.ASCII print(ifd[key]) ('Some Data',) Also contains a dictionary of tag types as read from the tiff image file, `tagtype`. Values are returned as a tuple. Deprecated since version 3.0.0. classmethod from_v2(_original : ImageFileDirectory_v2_) -> ImageFileDirectory_v1[[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v1.from_v2)¶ Returns an `ImageFileDirectory_v1` instance with the same data as is contained in the original `ImageFileDirectory_v2` instance. Returns: `ImageFileDirectory_v1` property tagdata¶ property tags¶ tagtype: [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]¶ Dictionary of tag types to_v2() -> ImageFileDirectory_v2[[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v1.to_v2)¶ Returns an `ImageFileDirectory_v2` instance with the same data as is contained in the original `ImageFileDirectory_v1` instance. Returns: `ImageFileDirectory_v2` class PIL.TiffImagePlugin.ImageFileDirectory_v2(_ifh : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") = b'II*\x00\x00\x00\x00\x00'_, _prefix : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_, _group : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v2)¶ Bases: [`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping "\(in Python v3.14\)") This class represents a TIFF tag directory. To speed things up, we don’t decode tags unless they’re asked for. Exposes a dictionary interface of the tags in the directory: ifd = ImageFileDirectory_v2() ifd[key] = 'Some Data' ifd.tagtype[key] = TiffTags.ASCII print(ifd[key]) 'Some Data' Individual values are returned as the strings or numbers, sequences are returned as tuples of the values. The tiff metadata type of each item is stored in a dictionary of tag types in `tagtype`. The types are read from a tiff file, guessed from the type added, or added manually. Data Structures: > * `self.tagtype = {}` > > * Key: numerical TIFF tag number > > * Value: integer corresponding to the data type from > [`TiffTags.TYPES`](TiffTags.html#PIL.TiffTags.PIL.TiffTags.TYPES > "PIL.TiffTags.PIL.TiffTags.TYPES") > > Added in version 3.0.0. > > ‘Internal’ data structures: > * `self._tags_v2 = {}` > > * Key: numerical TIFF tag number > > * Value: decoded data, as tuple for multiple values > > * `self._tagdata = {}` > > * Key: numerical TIFF tag number > > * Value: undecoded byte string from file > > * `self._tags_v1 = {}` > > * Key: numerical TIFF tag number > > * Value: decoded data in the v1 format > > Tags will be found in the private attributes `self._tagdata`, and in `self._tags_v2` once decoded. `self.legacy_api` is a value for internal use, and shouldn’t be changed from outside code. In cooperation with `ImageFileDirectory_v1`, if `legacy_api` is true, then decoded tags will be populated into both `_tags_v1` and `_tags_v2`. `_tags_v2` will be used if this IFD is used in the TIFF save routine. Tags should be read from `_tags_v1` if `legacy_api == true`. property legacy_api: [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)")¶ load(_fp : [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v2.load)¶ load_byte(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _legacy_api : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = True_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v2.load_byte)¶ load_double(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _legacy_api : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = True_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)"), ...]¶ load_float(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _legacy_api : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = True_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)"), ...]¶ load_long(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _legacy_api : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = True_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)"), ...]¶ load_long8(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _legacy_api : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = True_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)"), ...]¶ load_rational(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _legacy_api : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = True_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | IFDRational, ...][[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v2.load_rational)¶ load_short(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _legacy_api : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = True_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)"), ...]¶ load_signed_byte(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _legacy_api : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = True_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)"), ...]¶ load_signed_long(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _legacy_api : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = True_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)"), ...]¶ load_signed_rational(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _legacy_api : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = True_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")] | IFDRational, ...][[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v2.load_signed_rational)¶ load_signed_short(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _legacy_api : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = True_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)"), ...]¶ load_string(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _legacy_api : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = True_) -> [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v2.load_string)¶ load_undefined(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")_, _legacy_api : [bool](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.14\)") = True_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v2.load_undefined)¶ named() -> [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")][[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v2.named)¶ Returns: dict of name|key: value Returns the complete tag dictionary, with named tags where possible. property offset¶ property prefix¶ reset() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v2.reset)¶ save(_fp : [IO](https://docs.python.org/3/library/typing.html#typing.IO "\(in Python v3.14\)")[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_) -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v2.save)¶ tagtype: [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")]¶ Dictionary of tag types tobytes(_offset : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") = 0_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v2.tobytes)¶ write_byte(_data : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | IFDRational_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v2.write_byte)¶ write_double(_* values_)¶ write_float(_* values_)¶ write_long(_* values_)¶ write_long8(_* values_)¶ write_rational(_* values: IFDRational_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v2.write_rational)¶ write_short(_* values_)¶ write_signed_byte(_* values_)¶ write_signed_long(_* values_)¶ write_signed_rational(_* values: IFDRational_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v2.write_signed_rational)¶ write_signed_short(_* values_)¶ write_string(_value : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v2.write_string)¶ write_undefined(_value : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)") | IFDRational_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#ImageFileDirectory_v2.write_undefined)¶ class PIL.TiffImagePlugin.TiffImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/TiffImagePlugin.html#TiffImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'TIFF'¶ format_description = 'Adobe TIFF'¶ get_photoshop_blocks() -> [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [dict](https://docs.python.org/3/library/stdtypes.html#dict "\(in Python v3.14\)")[[str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)"), [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]][[source]](../_modules/PIL/TiffImagePlugin.html#TiffImageFile.get_photoshop_blocks)¶ Returns a dictionary of Photoshop “Image Resource Blocks”. The keys are the image resource ID. For more information, see Returns: Photoshop “Image Resource Blocks” in a dictionary. load() -> [Image.core.PixelAccess](PixelAccess.html#PixelAccess "PIL.Image.core.PixelAccess") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#TiffImageFile.load)¶ Load image data based on tile list load_end() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#TiffImageFile.load_end)¶ load_prepare() -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#TiffImageFile.load_prepare)¶ property n_frames: [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")¶ seek(_frame : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#TiffImageFile.seek)¶ Select a given frame as current image tag: ImageFileDirectory_v1¶ Legacy tag entries tag_v2: ImageFileDirectory_v2¶ Image file directory (tag dictionary) tell() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/TiffImagePlugin.html#TiffImageFile.tell)¶ Return the current frame number ## `WebPImagePlugin` module¶ class PIL.WebPImagePlugin.WebPImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/WebPImagePlugin.html#WebPImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'WEBP'¶ format_description = 'WebP image'¶ load() -> [Image.core.PixelAccess](PixelAccess.html#PixelAccess "PIL.Image.core.PixelAccess") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/WebPImagePlugin.html#WebPImageFile.load)¶ Load image data based on tile list load_seek(_pos : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/WebPImagePlugin.html#WebPImageFile.load_seek)¶ seek(_frame : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/WebPImagePlugin.html#WebPImageFile.seek)¶ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an `EOFError` exception. When a sequence file is opened, the library automatically seeks to frame 0. See [`tell()`](Image.html#PIL.Image.Image.tell "PIL.Image.Image.tell"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Parameters: **frame** – Frame number, starting at 0. Raises: [**EOFError**](https://docs.python.org/3/library/exceptions.html#EOFError "\(in Python v3.14\)") – If the call attempts to seek beyond the end of the sequence. tell() -> [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")[[source]](../_modules/PIL/WebPImagePlugin.html#WebPImageFile.tell)¶ Returns the current frame number. See [`seek()`](Image.html#PIL.Image.Image.seek "PIL.Image.Image.seek"). If defined, [`n_frames`](Image.html#PIL.Image.Image.n_frames "PIL.Image.Image.n_frames") refers to the number of available frames. Returns: Frame number, starting with 0. ## `WmfImagePlugin` module¶ class PIL.WmfImagePlugin.WmfStubImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/WmfImagePlugin.html#WmfStubImageFile)¶ Bases: [`StubImageFile`](ImageFile.html#PIL.ImageFile.StubImageFile "PIL.ImageFile.StubImageFile") format = 'WMF'¶ format_description = 'Windows Metafile'¶ load(_dpi : [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)") | [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)"), [float](https://docs.python.org/3/library/functions.html#float "\(in Python v3.14\)")] | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_) -> [Image.core.PixelAccess](PixelAccess.html#PixelAccess "PIL.Image.core.PixelAccess") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/WmfImagePlugin.html#WmfStubImageFile.load)¶ Load image data based on tile list PIL.WmfImagePlugin.register_handler(_handler : [StubHandler](ImageFile.html#PIL.ImageFile.StubHandler "PIL.ImageFile.StubHandler") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")_) -> [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)")[[source]](../_modules/PIL/WmfImagePlugin.html#register_handler)¶ Install application-specific WMF image handler. Parameters: **handler** – Handler object. ## `XVThumbImagePlugin` module¶ class PIL.XVThumbImagePlugin.XVThumbImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/XVThumbImagePlugin.html#XVThumbImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'XVThumb'¶ format_description = 'XV thumbnail image'¶ ## `XbmImagePlugin` module¶ class PIL.XbmImagePlugin.XbmImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/XbmImagePlugin.html#XbmImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'XBM'¶ format_description = 'X11 Bitmap'¶ ## `XpmImagePlugin` module¶ class PIL.XpmImagePlugin.XpmDecoder(_mode : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)")_, _* args: [Any](https://docs.python.org/3/library/typing.html#typing.Any "\(in Python v3.14\)")_)[[source]](../_modules/PIL/XpmImagePlugin.html#XpmDecoder)¶ Bases: [`PyDecoder`](ImageFile.html#PIL.ImageFile.PyDecoder "PIL.ImageFile.PyDecoder") decode(_buffer : [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [SupportsArrayInterface](Image.html#PIL.Image.SupportsArrayInterface "PIL.Image.SupportsArrayInterface")_) -> [tuple](https://docs.python.org/3/library/stdtypes.html#tuple "\(in Python v3.14\)")[[int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)"), [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")][[source]](../_modules/PIL/XpmImagePlugin.html#XpmDecoder.decode)¶ Override to perform the decoding process. Parameters: **buffer** – A bytes object with the data to be decoded. Returns: A tuple of `(bytes consumed, errcode)`. If finished with decoding return -1 for the bytes consumed. Err codes are from [`ImageFile.ERRORS`](ImageFile.html#PIL.ImageFile.ERRORS "PIL.ImageFile.ERRORS"). class PIL.XpmImagePlugin.XpmImageFile(_fp : [StrOrBytesPath](internal_modules.html#PIL._typing.StrOrBytesPath "PIL._typing.StrOrBytesPath") | IO[[bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")]_, _filename : [str](https://docs.python.org/3/library/stdtypes.html#str "\(in Python v3.14\)") | [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)") | [None](https://docs.python.org/3/library/constants.html#None "\(in Python v3.14\)") = None_)[[source]](../_modules/PIL/XpmImagePlugin.html#XpmImageFile)¶ Bases: [`ImageFile`](ImageFile.html#PIL.ImageFile.ImageFile "PIL.ImageFile.ImageFile") format = 'XPM'¶ format_description = 'X11 Pixel Map'¶ load_read(_read_bytes : [int](https://docs.python.org/3/library/functions.html#int "\(in Python v3.14\)")_) -> [bytes](https://docs.python.org/3/library/stdtypes.html#bytes "\(in Python v3.14\)")[[source]](../_modules/PIL/XpmImagePlugin.html#XpmImageFile.load_read)¶ [ Next Internal reference ](internal_design.html) [ Previous PIL package (autodoc of remaining modules) ](../PIL.html) Copyright (C) 1995-2011 Fredrik Lundh and contributors, 2010 Jeffrey A. Clark and contributors. Made with [Sphinx](https://www.sphinx-doc.org/) and [@pradyunsg](https://pradyunsg.me)'s [Furo](https://github.com/pradyunsg/furo) On this page * Plugin reference * `AvifImagePlugin` module * `AvifImageFile` * `AvifImageFile.format` * `AvifImageFile.format_description` * `AvifImageFile.load()` * `AvifImageFile.load_seek()` * `AvifImageFile.seek()` * `AvifImageFile.tell()` * `get_codec_version()` * `BmpImagePlugin` module * `BmpImageFile` * `BmpImageFile.BITFIELDS` * `BmpImageFile.COMPRESSIONS` * `BmpImageFile.JPEG` * `BmpImageFile.PNG` * `BmpImageFile.RAW` * `BmpImageFile.RLE4` * `BmpImageFile.RLE8` * `BmpImageFile.format` * `BmpImageFile.format_description` * `BmpImageFile.k` * `BmpImageFile.v` * `BmpRleDecoder` * `BmpRleDecoder.decode()` * `DibImageFile` * `DibImageFile.format` * `DibImageFile.format_description` * `BufrStubImagePlugin` module * `BufrStubImageFile` * `BufrStubImageFile.format` * `BufrStubImageFile.format_description` * `register_handler()` * `CurImagePlugin` module * `CurImageFile` * `CurImageFile.format` * `CurImageFile.format_description` * `DcxImagePlugin` module * `DcxImageFile` * `DcxImageFile.format` * `DcxImageFile.format_description` * `DcxImageFile.seek()` * `DcxImageFile.tell()` * `DdsImagePlugin` module * `D3DFMT` * `D3DFMT.A1` * `D3DFMT.A16B16G16R16` * `D3DFMT.A16B16G16R16F` * `D3DFMT.A1R5G5B5` * `D3DFMT.A2B10G10R10` * `D3DFMT.A2B10G10R10_XR_BIAS` * `D3DFMT.A2R10G10B10` * `D3DFMT.A2W10V10U10` * `D3DFMT.A32B32G32R32F` * `D3DFMT.A4L4` * `D3DFMT.A4R4G4B4` * `D3DFMT.A8` * `D3DFMT.A8B8G8R8` * `D3DFMT.A8L8` * `D3DFMT.A8P8` * `D3DFMT.A8R3G3B2` * `D3DFMT.A8R8G8B8` * `D3DFMT.ATI1` * `D3DFMT.ATI2` * `D3DFMT.BC4S` * `D3DFMT.BC4U` * `D3DFMT.BC5S` * `D3DFMT.BC5U` * `D3DFMT.BINARYBUFFER` * `D3DFMT.CxV8U8` * `D3DFMT.D15S1` * `D3DFMT.D16` * `D3DFMT.D16_LOCKABLE` * `D3DFMT.D24FS8` * `D3DFMT.D24S8` * `D3DFMT.D24X4S4` * `D3DFMT.D24X8` * `D3DFMT.D32` * `D3DFMT.D32F_LOCKABLE` * `D3DFMT.D32_LOCKABLE` * `D3DFMT.DX10` * `D3DFMT.DXT1` * `D3DFMT.DXT2` * `D3DFMT.DXT3` * `D3DFMT.DXT4` * `D3DFMT.DXT5` * `D3DFMT.G16R16` * `D3DFMT.G16R16F` * `D3DFMT.G32R32F` * `D3DFMT.G8R8_G8B8` * `D3DFMT.INDEX16` * `D3DFMT.INDEX32` * `D3DFMT.L16` * `D3DFMT.L6V5U5` * `D3DFMT.L8` * `D3DFMT.MULTI2_ARGB8` * `D3DFMT.P8` * `D3DFMT.Q16W16V16U16` * `D3DFMT.Q8W8V8U8` * `D3DFMT.R16F` * `D3DFMT.R32F` * `D3DFMT.R3G3B2` * `D3DFMT.R5G6B5` * `D3DFMT.R8G8B8` * `D3DFMT.R8G8_B8G8` * `D3DFMT.S8_LOCKABLE` * `D3DFMT.UNKNOWN` * `D3DFMT.UYVY` * `D3DFMT.V16U16` * `D3DFMT.V8U8` * `D3DFMT.VERTEXDATA` * `D3DFMT.X1R5G5B5` * `D3DFMT.X4R4G4B4` * `D3DFMT.X8B8G8R8` * `D3DFMT.X8L8V8U8` * `D3DFMT.X8R8G8B8` * `D3DFMT.YUY2` * `DDPF` * `DDPF.ALPHA` * `DDPF.ALPHAPIXELS` * `DDPF.FOURCC` * `DDPF.LUMINANCE` * `DDPF.PALETTEINDEXED8` * `DDPF.RGB` * `DDSCAPS` * `DDSCAPS.COMPLEX` * `DDSCAPS.MIPMAP` * `DDSCAPS.TEXTURE` * `DDSCAPS2` * `DDSCAPS2.CUBEMAP` * `DDSCAPS2.CUBEMAP_NEGATIVEX` * `DDSCAPS2.CUBEMAP_NEGATIVEY` * `DDSCAPS2.CUBEMAP_NEGATIVEZ` * `DDSCAPS2.CUBEMAP_POSITIVEX` * `DDSCAPS2.CUBEMAP_POSITIVEY` * `DDSCAPS2.CUBEMAP_POSITIVEZ` * `DDSCAPS2.VOLUME` * `DDSD` * `DDSD.CAPS` * `DDSD.DEPTH` * `DDSD.HEIGHT` * `DDSD.LINEARSIZE` * `DDSD.MIPMAPCOUNT` * `DDSD.PITCH` * `DDSD.PIXELFORMAT` * `DDSD.WIDTH` * `DXGI_FORMAT` * `DXGI_FORMAT.A8P8` * `DXGI_FORMAT.A8_UNORM` * `DXGI_FORMAT.AI44` * `DXGI_FORMAT.AYUV` * `DXGI_FORMAT.B4G4R4A4_UNORM` * `DXGI_FORMAT.B5G5R5A1_UNORM` * `DXGI_FORMAT.B5G6R5_UNORM` * `DXGI_FORMAT.B8G8R8A8_TYPELESS` * `DXGI_FORMAT.B8G8R8A8_UNORM` * `DXGI_FORMAT.B8G8R8A8_UNORM_SRGB` * `DXGI_FORMAT.B8G8R8X8_TYPELESS` * `DXGI_FORMAT.B8G8R8X8_UNORM` * `DXGI_FORMAT.B8G8R8X8_UNORM_SRGB` * `DXGI_FORMAT.BC1_TYPELESS` * `DXGI_FORMAT.BC1_UNORM` * `DXGI_FORMAT.BC1_UNORM_SRGB` * `DXGI_FORMAT.BC2_TYPELESS` * `DXGI_FORMAT.BC2_UNORM` * `DXGI_FORMAT.BC2_UNORM_SRGB` * `DXGI_FORMAT.BC3_TYPELESS` * `DXGI_FORMAT.BC3_UNORM` * `DXGI_FORMAT.BC3_UNORM_SRGB` * `DXGI_FORMAT.BC4_SNORM` * `DXGI_FORMAT.BC4_TYPELESS` * `DXGI_FORMAT.BC4_UNORM` * `DXGI_FORMAT.BC5_SNORM` * `DXGI_FORMAT.BC5_TYPELESS` * `DXGI_FORMAT.BC5_UNORM` * `DXGI_FORMAT.BC6H_SF16` * `DXGI_FORMAT.BC6H_TYPELESS` * `DXGI_FORMAT.BC6H_UF16` * `DXGI_FORMAT.BC7_TYPELESS` * `DXGI_FORMAT.BC7_UNORM` * `DXGI_FORMAT.BC7_UNORM_SRGB` * `DXGI_FORMAT.D16_UNORM` * `DXGI_FORMAT.D24_UNORM_S8_UINT` * `DXGI_FORMAT.D32_FLOAT` * `DXGI_FORMAT.D32_FLOAT_S8X24_UINT` * `DXGI_FORMAT.G8R8_G8B8_UNORM` * `DXGI_FORMAT.IA44` * `DXGI_FORMAT.NV11` * `DXGI_FORMAT.NV12` * `DXGI_FORMAT.OPAQUE_420` * `DXGI_FORMAT.P010` * `DXGI_FORMAT.P016` * `DXGI_FORMAT.P208` * `DXGI_FORMAT.P8` * `DXGI_FORMAT.R10G10B10A2_TYPELESS` * `DXGI_FORMAT.R10G10B10A2_UINT` * `DXGI_FORMAT.R10G10B10A2_UNORM` * `DXGI_FORMAT.R10G10B10_XR_BIAS_A2_UNORM` * `DXGI_FORMAT.R11G11B10_FLOAT` * `DXGI_FORMAT.R16G16B16A16_FLOAT` * `DXGI_FORMAT.R16G16B16A16_SINT` * `DXGI_FORMAT.R16G16B16A16_SNORM` * `DXGI_FORMAT.R16G16B16A16_TYPELESS` * `DXGI_FORMAT.R16G16B16A16_UINT` * `DXGI_FORMAT.R16G16B16A16_UNORM` * `DXGI_FORMAT.R16G16_FLOAT` * `DXGI_FORMAT.R16G16_SINT` * `DXGI_FORMAT.R16G16_SNORM` * `DXGI_FORMAT.R16G16_TYPELESS` * `DXGI_FORMAT.R16G16_UINT` * `DXGI_FORMAT.R16G16_UNORM` * `DXGI_FORMAT.R16_FLOAT` * `DXGI_FORMAT.R16_SINT` * `DXGI_FORMAT.R16_SNORM` * `DXGI_FORMAT.R16_TYPELESS` * `DXGI_FORMAT.R16_UINT` * `DXGI_FORMAT.R16_UNORM` * `DXGI_FORMAT.R1_UNORM` * `DXGI_FORMAT.R24G8_TYPELESS` * `DXGI_FORMAT.R24_UNORM_X8_TYPELESS` * `DXGI_FORMAT.R32G32B32A32_FLOAT` * `DXGI_FORMAT.R32G32B32A32_SINT` * `DXGI_FORMAT.R32G32B32A32_TYPELESS` * `DXGI_FORMAT.R32G32B32A32_UINT` * `DXGI_FORMAT.R32G32B32_FLOAT` * `DXGI_FORMAT.R32G32B32_SINT` * `DXGI_FORMAT.R32G32B32_TYPELESS` * `DXGI_FORMAT.R32G32B32_UINT` * `DXGI_FORMAT.R32G32_FLOAT` * `DXGI_FORMAT.R32G32_SINT` * `DXGI_FORMAT.R32G32_TYPELESS` * `DXGI_FORMAT.R32G32_UINT` * `DXGI_FORMAT.R32G8X24_TYPELESS` * `DXGI_FORMAT.R32_FLOAT` * `DXGI_FORMAT.R32_FLOAT_X8X24_TYPELESS` * `DXGI_FORMAT.R32_SINT` * `DXGI_FORMAT.R32_TYPELESS` * `DXGI_FORMAT.R32_UINT` * `DXGI_FORMAT.R8G8B8A8_SINT` * `DXGI_FORMAT.R8G8B8A8_SNORM` * `DXGI_FORMAT.R8G8B8A8_TYPELESS` * `DXGI_FORMAT.R8G8B8A8_UINT` * `DXGI_FORMAT.R8G8B8A8_UNORM` * `DXGI_FORMAT.R8G8B8A8_UNORM_SRGB` * `DXGI_FORMAT.R8G8_B8G8_UNORM` * `DXGI_FORMAT.R8G8_SINT` * `DXGI_FORMAT.R8G8_SNORM` * `DXGI_FORMAT.R8G8_TYPELESS` * `DXGI_FORMAT.R8G8_UINT` * `DXGI_FORMAT.R8G8_UNORM` * `DXGI_FORMAT.R8_SINT` * `DXGI_FORMAT.R8_SNORM` * `DXGI_FORMAT.R8_TYPELESS` * `DXGI_FORMAT.R8_UINT` * `DXGI_FORMAT.R8_UNORM` * `DXGI_FORMAT.R9G9B9E5_SHAREDEXP` * `DXGI_FORMAT.SAMPLER_FEEDBACK_MIN_MIP_OPAQUE` * `DXGI_FORMAT.SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE` * `DXGI_FORMAT.UNKNOWN` * `DXGI_FORMAT.V208` * `DXGI_FORMAT.V408` * `DXGI_FORMAT.X24_TYPELESS_G8_UINT` * `DXGI_FORMAT.X32_TYPELESS_G8X24_UINT` * `DXGI_FORMAT.Y210` * `DXGI_FORMAT.Y216` * `DXGI_FORMAT.Y410` * `DXGI_FORMAT.Y416` * `DXGI_FORMAT.YUY2` * `DdsImageFile` * `DdsImageFile.format` * `DdsImageFile.format_description` * `DdsImageFile.load_seek()` * `DdsRgbDecoder` * `DdsRgbDecoder.decode()` * `EpsImagePlugin` module * `EpsImageFile` * `EpsImageFile.format` * `EpsImageFile.format_description` * `EpsImageFile.load()` * `EpsImageFile.load_seek()` * `EpsImageFile.mode_map` * `Ghostscript()` * `has_ghostscript()` * `FitsImagePlugin` module * `FitsGzipDecoder` * `FitsGzipDecoder.decode()` * `FitsImageFile` * `FitsImageFile.format` * `FitsImageFile.format_description` * `FliImagePlugin` module * `FliImageFile` * `FliImageFile.format` * `FliImageFile.format_description` * `FliImageFile.seek()` * `FliImageFile.tell()` * `FpxImagePlugin` module * `FpxImageFile` * `FpxImageFile.close()` * `FpxImageFile.format` * `FpxImageFile.format_description` * `FpxImageFile.load()` * `GbrImagePlugin` module * `GbrImageFile` * `GbrImageFile.format` * `GbrImageFile.format_description` * `GbrImageFile.load()` * `GifImagePlugin` module * `GifImageFile` * `GifImageFile.data()` * `GifImageFile.format` * `GifImageFile.format_description` * `GifImageFile.global_palette` * `GifImageFile.is_animated` * `GifImageFile.load_end()` * `GifImageFile.load_prepare()` * `GifImageFile.n_frames` * `GifImageFile.seek()` * `GifImageFile.tell()` * `LOADING_STRATEGY` * `LoadingStrategy` * `LoadingStrategy.RGB_AFTER_DIFFERENT_PALETTE_ONLY` * `LoadingStrategy.RGB_AFTER_FIRST` * `LoadingStrategy.RGB_ALWAYS` * `get_interlace()` * `getdata()` * `getheader()` * `GribStubImagePlugin` module * `GribStubImageFile` * `GribStubImageFile.format` * `GribStubImageFile.format_description` * `register_handler()` * `Hdf5StubImagePlugin` module * `HDF5StubImageFile` * `HDF5StubImageFile.format` * `HDF5StubImageFile.format_description` * `register_handler()` * `IcnsImagePlugin` module * `IcnsFile` * `IcnsFile.SIZES` * `IcnsFile.bestsize()` * `IcnsFile.dataforsize()` * `IcnsFile.getimage()` * `IcnsFile.itersizes()` * `IcnsImageFile` * `IcnsImageFile.format` * `IcnsImageFile.format_description` * `IcnsImageFile.load()` * `IcnsImageFile.size` * `nextheader()` * `read_32()` * `read_32t()` * `read_mk()` * `read_png_or_jpeg2000()` * `IcoImagePlugin` module * `IcoFile` * `IcoFile.frame()` * `IcoFile.getentryindex()` * `IcoFile.getimage()` * `IcoFile.sizes()` * `IcoImageFile` * `IcoImageFile.format` * `IcoImageFile.format_description` * `IcoImageFile.load()` * `IcoImageFile.load_seek()` * `IcoImageFile.size` * `IconHeader` * `IconHeader.bpp` * `IconHeader.color_depth` * `IconHeader.dim` * `IconHeader.height` * `IconHeader.nb_color` * `IconHeader.offset` * `IconHeader.planes` * `IconHeader.reserved` * `IconHeader.size` * `IconHeader.square` * `IconHeader.width` * `ImImagePlugin` module * `ImImageFile` * `ImImageFile.format` * `ImImageFile.format_description` * `ImImageFile.is_animated` * `ImImageFile.n_frames` * `ImImageFile.seek()` * `ImImageFile.tell()` * `number()` * `ImtImagePlugin` module * `ImtImageFile` * `ImtImageFile.format` * `ImtImageFile.format_description` * `IptcImagePlugin` module * `IptcImageFile` * `IptcImageFile.field()` * `IptcImageFile.format` * `IptcImageFile.format_description` * `IptcImageFile.getint()` * `IptcImageFile.load()` * `getiptcinfo()` * `JpegImagePlugin` module * `APP()` * `COM()` * `DQT()` * `JpegImageFile` * `JpegImageFile.draft()` * `JpegImageFile.format` * `JpegImageFile.format_description` * `JpegImageFile.load_djpeg()` * `JpegImageFile.load_read()` * `SOF()` * `Skip()` * `get_sampling()` * `jpeg_factory()` * `Jpeg2KImagePlugin` module * `BoxReader` * `BoxReader.has_next_box()` * `BoxReader.next_box_type()` * `BoxReader.read_boxes()` * `BoxReader.read_fields()` * `Jpeg2KImageFile` * `Jpeg2KImageFile.format` * `Jpeg2KImageFile.format_description` * `Jpeg2KImageFile.load()` * `Jpeg2KImageFile.reduce` * `McIdasImagePlugin` module * `McIdasImageFile` * `McIdasImageFile.format` * `McIdasImageFile.format_description` * `MicImagePlugin` module * `MicImageFile` * `MicImageFile.close()` * `MicImageFile.format` * `MicImageFile.format_description` * `MicImageFile.seek()` * `MicImageFile.tell()` * `MpegImagePlugin` module * `BitStream` * `BitStream.next()` * `BitStream.peek()` * `BitStream.read()` * `BitStream.skip()` * `MpegImageFile` * `MpegImageFile.format` * `MpegImageFile.format_description` * `MpoImagePlugin` module * `MpoImageFile` * `MpoImageFile.adopt()` * `MpoImageFile.format` * `MpoImageFile.format_description` * `MpoImageFile.load_seek()` * `MpoImageFile.seek()` * `MpoImageFile.tell()` * `MspImagePlugin` module * `MspDecoder` * `MspDecoder.decode()` * `MspImageFile` * `MspImageFile.format` * `MspImageFile.format_description` * `PalmImagePlugin` module * `build_prototype_image()` * `PcdImagePlugin` module * `PcdImageFile` * `PcdImageFile.format` * `PcdImageFile.format_description` * `PcdImageFile.load_end()` * `PcdImageFile.load_prepare()` * `PcxImagePlugin` module * `PcxImageFile` * `PcxImageFile.format` * `PcxImageFile.format_description` * `PdfImagePlugin` module * `PixarImagePlugin` module * `PixarImageFile` * `PixarImageFile.format` * `PixarImageFile.format_description` * `PngImagePlugin` module * `Blend` * `Blend.OP_OVER` * `Blend.OP_SOURCE` * `ChunkStream` * `ChunkStream.call()` * `ChunkStream.close()` * `ChunkStream.crc()` * `ChunkStream.crc_skip()` * `ChunkStream.push()` * `ChunkStream.read()` * `ChunkStream.verify()` * `ChunkStream.fp` * `ChunkStream.queue` * `Disposal` * `Disposal.OP_BACKGROUND` * `Disposal.OP_NONE` * `Disposal.OP_PREVIOUS` * `PngImageFile` * `PngImageFile.getexif()` * `PngImageFile.load_end()` * `PngImageFile.load_prepare()` * `PngImageFile.load_read()` * `PngImageFile.seek()` * `PngImageFile.tell()` * `PngImageFile.verify()` * `PngImageFile.format` * `PngImageFile.format_description` * `PngImageFile.text` * `PngStream` * `PngStream.check_text_memory()` * `PngStream.chunk_IDAT()` * `PngStream.chunk_IEND()` * `PngStream.chunk_IHDR()` * `PngStream.chunk_PLTE()` * `PngStream.chunk_acTL()` * `PngStream.chunk_cHRM()` * `PngStream.chunk_eXIf()` * `PngStream.chunk_fcTL()` * `PngStream.chunk_fdAT()` * `PngStream.chunk_gAMA()` * `PngStream.chunk_iCCP()` * `PngStream.chunk_iTXt()` * `PngStream.chunk_pHYs()` * `PngStream.chunk_sRGB()` * `PngStream.chunk_tEXt()` * `PngStream.chunk_tRNS()` * `PngStream.chunk_zTXt()` * `PngStream.rewind()` * `PngStream.save_rewind()` * `PngStream.im_custom_mimetype` * `PngStream.im_info` * `PngStream.im_n_frames` * `PngStream.im_palette` * `PngStream.im_text` * `PngStream.im_tile` * `getchunks()` * `is_cid()` * `putchunk()` * `MAX_TEXT_CHUNK` * `MAX_TEXT_MEMORY` * `PpmImagePlugin` module * `PpmDecoder` * `PpmDecoder.decode()` * `PpmImageFile` * `PpmImageFile.format` * `PpmImageFile.format_description` * `PpmPlainDecoder` * `PpmPlainDecoder.decode()` * `PsdImagePlugin` module * `PsdImageFile` * `PsdImageFile.format` * `PsdImageFile.format_description` * `PsdImageFile.is_animated` * `PsdImageFile.layers` * `PsdImageFile.n_frames` * `PsdImageFile.seek()` * `PsdImageFile.tell()` * `SgiImagePlugin` module * `SGI16Decoder` * `SGI16Decoder.decode()` * `SgiImageFile` * `SgiImageFile.format` * `SgiImageFile.format_description` * `SpiderImagePlugin` module * `SpiderImageFile` * `SpiderImageFile.convert2byte()` * `SpiderImageFile.format` * `SpiderImageFile.format_description` * `SpiderImageFile.is_animated` * `SpiderImageFile.n_frames` * `SpiderImageFile.seek()` * `SpiderImageFile.tell()` * `SpiderImageFile.tkPhotoImage()` * `isInt()` * `isSpiderHeader()` * `isSpiderImage()` * `loadImageSeries()` * `makeSpiderHeader()` * `SunImagePlugin` module * `SunImageFile` * `SunImageFile.format` * `SunImageFile.format_description` * `TgaImagePlugin` module * `TgaImageFile` * `TgaImageFile.format` * `TgaImageFile.format_description` * `TgaImageFile.load_end()` * `TiffImagePlugin` module * `AppendingTiffWriter` * `AppendingTiffWriter.Tags` * `AppendingTiffWriter.close()` * `AppendingTiffWriter.f` * `AppendingTiffWriter.fieldSizes` * `AppendingTiffWriter.finalize()` * `AppendingTiffWriter.fixIFD()` * `AppendingTiffWriter.fixOffsets()` * `AppendingTiffWriter.goToEnd()` * `AppendingTiffWriter.newFrame()` * `AppendingTiffWriter.readLong()` * `AppendingTiffWriter.readShort()` * `AppendingTiffWriter.rewriteLastLong()` * `AppendingTiffWriter.rewriteLastShort()` * `AppendingTiffWriter.rewriteLastShortToLong()` * `AppendingTiffWriter.seek()` * `AppendingTiffWriter.setEndian()` * `AppendingTiffWriter.setup()` * `AppendingTiffWriter.skipIFDs()` * `AppendingTiffWriter.tell()` * `AppendingTiffWriter.write()` * `AppendingTiffWriter.writeLong()` * `AppendingTiffWriter.writeShort()` * `IFDRational` * `IFDRational.denominator` * `IFDRational.limit_rational()` * `IFDRational.numerator` * `ImageFileDirectory` * `ImageFileDirectory_v1` * `ImageFileDirectory_v1.from_v2()` * `ImageFileDirectory_v1.tagdata` * `ImageFileDirectory_v1.tags` * `ImageFileDirectory_v1.tagtype` * `ImageFileDirectory_v1.to_v2()` * `ImageFileDirectory_v2` * `ImageFileDirectory_v2.legacy_api` * `ImageFileDirectory_v2.load()` * `ImageFileDirectory_v2.load_byte()` * `ImageFileDirectory_v2.load_double()` * `ImageFileDirectory_v2.load_float()` * `ImageFileDirectory_v2.load_long()` * `ImageFileDirectory_v2.load_long8()` * `ImageFileDirectory_v2.load_rational()` * `ImageFileDirectory_v2.load_short()` * `ImageFileDirectory_v2.load_signed_byte()` * `ImageFileDirectory_v2.load_signed_long()` * `ImageFileDirectory_v2.load_signed_rational()` * `ImageFileDirectory_v2.load_signed_short()` * `ImageFileDirectory_v2.load_string()` * `ImageFileDirectory_v2.load_undefined()` * `ImageFileDirectory_v2.named()` * `ImageFileDirectory_v2.offset` * `ImageFileDirectory_v2.prefix` * `ImageFileDirectory_v2.reset()` * `ImageFileDirectory_v2.save()` * `ImageFileDirectory_v2.tagtype` * `ImageFileDirectory_v2.tobytes()` * `ImageFileDirectory_v2.write_byte()` * `ImageFileDirectory_v2.write_double()` * `ImageFileDirectory_v2.write_float()` * `ImageFileDirectory_v2.write_long()` * `ImageFileDirectory_v2.write_long8()` * `ImageFileDirectory_v2.write_rational()` * `ImageFileDirectory_v2.write_short()` * `ImageFileDirectory_v2.write_signed_byte()` * `ImageFileDirectory_v2.write_signed_long()` * `ImageFileDirectory_v2.write_signed_rational()` * `ImageFileDirectory_v2.write_signed_short()` * `ImageFileDirectory_v2.write_string()` * `ImageFileDirectory_v2.write_undefined()` * `TiffImageFile` * `TiffImageFile.format` * `TiffImageFile.format_description` * `TiffImageFile.get_photoshop_blocks()` * `TiffImageFile.load()` * `TiffImageFile.load_end()` * `TiffImageFile.load_prepare()` * `TiffImageFile.n_frames` * `TiffImageFile.seek()` * `TiffImageFile.tag` * `TiffImageFile.tag_v2` * `TiffImageFile.tell()` * `WebPImagePlugin` module * `WebPImageFile` * `WebPImageFile.format` * `WebPImageFile.format_description` * `WebPImageFile.load()` * `WebPImageFile.load_seek()` * `WebPImageFile.seek()` * `WebPImageFile.tell()` * `WmfImagePlugin` module * `WmfStubImageFile` * `WmfStubImageFile.format` * `WmfStubImageFile.format_description` * `WmfStubImageFile.load()` * `register_handler()` * `XVThumbImagePlugin` module * `XVThumbImageFile` * `XVThumbImageFile.format` * `XVThumbImageFile.format_description` * `XbmImagePlugin` module * `XbmImageFile` * `XbmImageFile.format` * `XbmImageFile.format_description` * `XpmImagePlugin` module * `XpmDecoder` * `XpmDecoder.decode()` * `XpmImageFile` * `XpmImageFile.format` * `XpmImageFile.format_description` * `XpmImageFile.load_read()` *[/]: Positional-only parameter separator (PEP 570)