AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS' (or 'ImageDraw' object has no attribute 'textsize', 'getsize', any name): which Pillow removed it and what to use
Pillow 10.0.0 (2023-07-01) removed Image.ANTIALIAS (use Image.LANCZOS), Image.LINEAR and Image.CUBIC (BILINEAR, BICUBIC), ImageDraw.textsize (use textbbox or textlength) and font.getsize (use getbbox or getlength); 9.1 to 9.5 warned. Pillow 12.0.0 removed ImageMath.eval (use lambda_eval or unsafe_eval). If the error comes from a library you did not write, upgrade the library or pin Pillow below the release that removed the name. Paste the error below for the release-by-release answer.
Examples:
Runs in your browser on the data in this page (pillow_names.json); nothing you paste is sent anywhere.
Which release removed it, and what replaces it?
42 names that one Pillow release has and a later one does not (28 of them in 10.0.0). "Instead" is Pillow's own deprecation text from the last release that had the name (38 of 42), except where marked.
| Name | Removed in | Instead |
|---|---|---|
PIL.Image.fromstring | 8.0.0 | Use Image.frombytes(mode, size, data). (our note) |
PIL.Image.Image.fromstring | 8.0.0 | Use im.frombytes(...). (our note) |
PIL.Image.Image.offset | 8.0.0 | From PIL.ImageChops import offset (still there in 13.0.0). |
PIL.Image.Image.tostring | 8.0.0 | Use im.tobytes(). (our note) |
PIL.ImageFile.raise_ioerror | 9.0.0 | raise_ioerror is deprecated and will be removed in Pillow 9 (2022-01-02). Use raise_oserror instead. |
PIL.Image.ANTIALIAS | 10.0.0 | ANTIALIAS is deprecated and will be removed in Pillow 10 (2023-07-01). Use LANCZOS or Resampling.LANCZOS instead. |
PIL.Image.coerce_e | 10.0.0 | coerce_e is deprecated and will be removed in Pillow 10. |
PIL.Image.CONTAINER | 10.0.0 | Image categories are deprecated and will be removed in Pillow 10 (2023-07-01). Use is_animated instead. |
PIL.Image.CUBIC | 10.0.0 | CUBIC is deprecated and will be removed in Pillow 10 (2023-07-01). Use BICUBIC or Resampling.BICUBIC instead. |
PIL.Image.LINEAR | 10.0.0 | LINEAR is deprecated and will be removed in Pillow 10 (2023-07-01). Use BILINEAR or Resampling.BILINEAR instead. |
PIL.Image.NORMAL | 10.0.0 | Image categories are deprecated and will be removed in Pillow 10 (2023-07-01). Use is_animated instead. |
PIL.Image.SEQUENCE | 10.0.0 | Image categories are deprecated and will be removed in Pillow 10 (2023-07-01). Use is_animated instead. |
PIL.ImageCms.DIRECTION_INPUT | 10.0.0 | DIRECTION_INPUT is deprecated and will be removed in Pillow 10 (2023-07-01). Use Direction.INPUT instead. |
PIL.ImageCms.DIRECTION_OUTPUT | 10.0.0 | DIRECTION_OUTPUT is deprecated and will be removed in Pillow 10 (2023-07-01). Use Direction.OUTPUT instead. |
PIL.ImageCms.DIRECTION_PROOF | 10.0.0 | DIRECTION_PROOF is deprecated and will be removed in Pillow 10 (2023-07-01). Use Direction.PROOF instead. |
PIL.ImageCms.INTENT_ABSOLUTE_COLORIMETRIC | 10.0.0 | INTENT_ABSOLUTE_COLORIMETRIC is deprecated and will be removed in Pillow 10 (2023-07-01). Use Intent.ABSOLUTE_COLORIMETRIC instead. |
PIL.ImageCms.INTENT_PERCEPTUAL | 10.0.0 | INTENT_PERCEPTUAL is deprecated and will be removed in Pillow 10 (2023-07-01). Use Intent.PERCEPTUAL instead. |
PIL.ImageCms.INTENT_RELATIVE_COLORIMETRIC | 10.0.0 | INTENT_RELATIVE_COLORIMETRIC is deprecated and will be removed in Pillow 10 (2023-07-01). Use Intent.RELATIVE_COLORIMETRIC instead. |
PIL.ImageCms.INTENT_SATURATION | 10.0.0 | INTENT_SATURATION is deprecated and will be removed in Pillow 10 (2023-07-01). Use Intent.SATURATION instead. |
PIL.ImageDraw.ImageDraw.multiline_textsize | 10.0.0 | multiline_textsize is deprecated and will be removed in Pillow 10. Use multiline_textbbox instead. |
PIL.ImageDraw.ImageDraw.textsize | 10.0.0 | textsize is deprecated and will be removed in Pillow 10. Use textbbox or textlength instead. |
PIL.ImageFont.LAYOUT_BASIC | 10.0.0 | LAYOUT_BASIC is deprecated and will be removed in Pillow 10 (2023-07-01). Use Layout.BASIC instead. |
PIL.ImageFont.LAYOUT_RAQM | 10.0.0 | LAYOUT_RAQM is deprecated and will be removed in Pillow 10 (2023-07-01). Use Layout.RAQM instead. |
PIL.ImageFont.FreeTypeFont.getoffset | 10.0.0 | getoffset is deprecated and will be removed in Pillow 10. Use getbbox instead. |
PIL.ImageFont.FreeTypeFont.getsize | 10.0.0 | getsize is deprecated and will be removed in Pillow 10. Use getbbox or getlength instead. |
PIL.ImageFont.FreeTypeFont.getsize_multiline | 10.0.0 | getsize_multiline is deprecated and will be removed in Pillow 10. Use ImageDraw.multiline_textbbox instead. |
PIL.ImageFont.ImageFont.getsize | 10.0.0 | getsize is deprecated and will be removed in Pillow 10. Use getbbox or getlength instead. |
PIL.JpegImagePlugin.convert_dict_qtables | 10.0.0 | convert_dict_qtables is deprecated and will be removed in Pillow 10. Use Conversion is no longer needed instead. |
PIL.PngImagePlugin.APNG_BLEND_OP_OVER | 10.0.0 | APNG_BLEND_OP_OVER is deprecated and will be removed in Pillow 10 (2023-07-01). Use Blend.OP_OVER instead. |
PIL.PngImagePlugin.APNG_BLEND_OP_SOURCE | 10.0.0 | APNG_BLEND_OP_SOURCE is deprecated and will be removed in Pillow 10 (2023-07-01). Use Blend.OP_SOURCE instead. |
PIL.PngImagePlugin.APNG_DISPOSE_OP_BACKGROUND | 10.0.0 | APNG_DISPOSE_OP_BACKGROUND is deprecated and will be removed in Pillow 10 (2023-07-01). Use Disposal.OP_BACKGROUND instead. |
PIL.PngImagePlugin.APNG_DISPOSE_OP_NONE | 10.0.0 | APNG_DISPOSE_OP_NONE is deprecated and will be removed in Pillow 10 (2023-07-01). Use Disposal.OP_NONE instead. |
PIL.PngImagePlugin.APNG_DISPOSE_OP_PREVIOUS | 10.0.0 | APNG_DISPOSE_OP_PREVIOUS is deprecated and will be removed in Pillow 10 (2023-07-01). Use Disposal.OP_PREVIOUS instead. |
PIL.Image.isImageType | 12.0.0 | Image.isImageType(im) is deprecated and will be removed in Pillow 12. Use isinstance(im, Image.Image) instead. |
PIL.ImageCms.DESCRIPTION | 12.0.0 | PIL.ImageCms.DESCRIPTION is deprecated and will be removed in Pillow 12 (2025-10-15) |
PIL.ImageCms.FLAGS | 12.0.0 | PIL.ImageCms.FLAGS is deprecated and will be removed in Pillow 12 (2025-10-15). Use PIL.ImageCms.Flags instead. |
PIL.ImageCms.VERSION | 12.0.0 | PIL.ImageCms.VERSION is deprecated and will be removed in Pillow 12 (2025-10-15) |
PIL.ImageCms.versions | 12.0.0 | PIL.ImageCms.versions() is deprecated and will be removed in Pillow 12. Use (PIL.features.version("littlecms2"), sys.version, PIL.__version__) instead. |
PIL.ImageFile.raise_oserror | 12.0.0 | raise_oserror is deprecated and will be removed in Pillow 12. Use It is only useful for translating error codes returned by a codec's decode() method, which ImageFile already does automatically. instead. |
PIL.ImageMath.eval | 12.0.0 | ImageMath.eval is deprecated and will be removed in Pillow 12. Use ImageMath.lambda_eval or ImageMath.unsafe_eval instead. |
PIL.Image.Image.get_child_images | 13.0.0 | Image.Image.get_child_images is deprecated and will be removed in Pillow 13. |
PIL.ImageSequence.Image | 13.0.0 | Image.Image.getdata is deprecated and will be removed in Pillow 14. Use get_flattened_data instead. |
How was this measured?
Each of 28 Pillow releases (every minor from 7.0.0, plus the latest) was installed from PyPI in its own environment, the public names of the PIL modules and of the Image, ImageDraw, FreeTypeFont and ImageFont classes were listed with dir(), and getattr was run for the union of all names in every release. Releases: 7.0.0 (Python 3.8), 7.1.0 (Python 3.8), 7.2.0 (Python 3.8), 8.0.0 (Python 3.8), 8.1.0 (Python 3.8), 8.2.0 (Python 3.8), 8.3.0 (Python 3.8), 8.4.0 (Python 3.8), 9.0.0 (Python 3.8), 9.1.0 (Python 3.8), 9.2.0 (Python 3.8), 9.3.0 (Python 3.8), 9.4.0 (Python 3.8), 9.5.0 (Python 3.8), 10.0.0 (Python 3.8), 10.1.0 (Python 3.8), 10.2.0 (Python 3.8), 10.3.0 (Python 3.8), 10.4.0 (Python 3.8), 11.0.0 (Python 3.9), 11.1.0 (Python 3.9), 11.2.1 (Python 3.9), 11.3.0 (Python 3.9), 12.0.0 (Python 3.12), 12.1.0 (Python 3.12), 12.2.0 (Python 3.12), 12.3.0 (Python 3.13), 13.0.0 (Python 3.13). Pillow's modules have no __all__, so the table keeps class members and the names Pillow itself deprecated (a warning on access, or a deprecate() call or warning in the definition); helpers a module merely imported are left out, but the lookup still answers for them. The text is read from the installed source of the last release that had the name; Pillow's deprecate("textsize", 10, "textbbox or textlength") calls are turned into the sentence its helper prints. ImageTk, ImageQt and ImageGrab were not read (their import depends on tkinter, Qt or a display).
Patch releases were not read: a name removed in x.y.1 shows at the next minor.
Questions
How do I fix "module 'PIL.Image' has no attribute 'ANTIALIAS'"?
Pillow 10.0.0 (2023-07-01) removed Image.ANTIALIAS; 9.1 to 9.5 warned. Use Image.LANCZOS (the same filter), or Image.Resampling.LANCZOS, which exists from 9.1.0: img.resize((w, h), Image.LANCZOS). The same release removed Image.LINEAR (use BILINEAR) and Image.CUBIC (use BICUBIC). If the error comes from a library, upgrade it, or pin pillow<10.
How do I fix "'ImageDraw' object has no attribute 'textsize'"?
Pillow 10.0.0 removed ImageDraw.textsize and multiline_textsize. Use draw.textbbox((0, 0), text, font=font), which returns (left, top, right, bottom): width = right - left, height = bottom - top; or draw.textlength(text, font=font) for the width alone.
How do I fix "'FreeTypeFont' object has no attribute 'getsize'"?
Pillow 10.0.0 removed font.getsize, getsize_multiline and getoffset. Use font.getbbox(text) (left, top, right, bottom) or font.getlength(text) for the advance width.
How do I fix "module 'PIL.ImageMath' has no attribute 'eval'"?
Pillow 12.0.0 (2025-10-15) removed ImageMath.eval. Use ImageMath.lambda_eval with a function, or ImageMath.unsafe_eval for a string expression you trust (it runs Python code).
Sources
- The Pillow wheels on PyPI, installed and run, and their source as installed (PIL/_deprecate.py for the wording); the release dates are PyPI's.
- Pillow's list of deprecations and removals.
The same data as JSON: pillow_names.json, licensed CC BY 4.0.
Related: "No module named 'torchvision.transforms.functional_tensor'" · "module 'numpy' has no attribute 'float_'" · "cannot import name 'imread' from 'scipy.misc'".