

Image moduleImageChops (“channel operations”) moduleImageCms moduleImageColor moduleImageDraw moduleImageEnhance moduleImageFile moduleImageFilter moduleImageFont moduleImageGrab moduleImageMath moduleImageMorph moduleImageOps moduleImagePalette moduleImagePath moduleImageQt moduleImageSequence moduleImageShow moduleImageStat moduleImageText moduleImageTk moduleImageTransform moduleImageWin module (Windows-only)ExifTags moduleTiffTags moduleJpegPresets modulePSDraw modulePixelAccess classfeatures moduleAn additional decompression bomb check has been added for the GIF format.
Deprecated since version 9.2.0.
Qt 5 reached end-of-life on 2020-12-08 foropen-source users (and will reach EOL on 2023-12-08 for commercial licence holders).
Support for PyQt5 and PySide2 has been deprecated fromImageQt and will be removedin Pillow 10 (2023-07-01). Upgrade toPyQt6 orPySide6 instead.
Deprecated since version 9.2.0.
The undocumentedfill parameter ofFreeTypeFont.getmask2()has been deprecated and will be removed in Pillow 10 (2023-07-01).
Deprecated since version 9.2.0.
Thebox parameter is unused. It will be removed in Pillow 10.0.0 (2023-07-01).
Deprecated since version 9.2.0.
This undocumented method has been deprecated and will be removed in Pillow 10(2023-07-01).
Deprecated since version 9.2.0.
Several functions for computing the size and offset of rendered texthave been deprecated and will be removed in Pillow 10 (2023-07-01):
Deprecated | Use instead |
|---|---|
| |
| |
| |
| |
|
|
|
Previous code:
fromPILimportImage,ImageDraw,ImageFontfont=ImageFont.truetype("Tests/fonts/FreeMono.ttf")width,height=font.getsize("Hello world")left,top=font.getoffset("Hello world")im=Image.new("RGB",(100,100))draw=ImageDraw.Draw(im)width,height=draw.textsize("Hello world",font)width,height=font.getsize_multiline("Hello\nworld")width,height=draw.multiline_textsize("Hello\nworld",font)
Use instead:
fromPILimportImage,ImageDraw,ImageFontfont=ImageFont.truetype("Tests/fonts/FreeMono.ttf")left,top,right,bottom=font.getbbox("Hello world")width,height=right-left,bottom-topim=Image.new("RGB",(100,100))draw=ImageDraw.Draw(im)width=draw.textlength("Hello world",font)left,top,right,bottom=draw.multiline_textbbox((0,0),"Hello\nworld",font)width,height=right-left,bottom-top
Previously, thesize methods returned aheight that included the verticaloffset of the text, while the newbbox methods distinguish this as atopoffset.

If you are using these methods for aligning text, consider usingText anchors insteadwhich avoid issues that can occur with non-English text or unusual fonts.For example, instead of the following code:
fromPILimportImage,ImageDraw,ImageFontfont=ImageFont.truetype("Tests/fonts/FreeMono.ttf")im=Image.new("RGB",(100,100))draw=ImageDraw.Draw(im)width,height=draw.textsize("Hello world",font)x,y=(100-width)/2,(100-height)/2draw.text((x,y),"Hello world",font=font)
Use instead:
fromPILimportImage,ImageDraw,ImageFontfont=ImageFont.truetype("Tests/fonts/FreeMono.ttf")im=Image.new("RGB",(100,100))draw=ImageDraw.Draw(im)draw.text((100/2,100/2),"Hello world",font=font,anchor="mm")
Addedapply_transparency(), a method to take a P mode imagewith “transparency” inim.info, and apply the transparency to the palette instead.The image’s palette mode will become “RGBA”, and “transparency” will be removed fromim.info.
Ingrab() on Linux, ifxdisplay isNone thengnome-screenshot will be used to capture the display if it is installed. To capturethe default X11 display instead, passxdisplay="".