{"id":301,"library":"pillow","title":"Pillow","description":"Pillow is a Python Imaging Library (PIL) fork that adds image processing capabilities to Python. It supports extensive file formats and provides efficient internal representations. The current version is 12.1.1, released on February 11, 2026, with a regular release cadence.","status":"active","version":"12.1.1","language":"python","source_language":"en","source_url":"https://github.com/python-pillow/Pillow","tags":["image processing","PIL","Python"],"install":[{"cmd":"pip install pillow","lang":"bash","label":"Install Pillow"}],"dependencies":[{"reason":"Required for JPEG support","package":"libjpeg","optional":false},{"reason":"Required for PNG support","package":"zlib","optional":false},{"reason":"Required for TIFF support","package":"libtiff","optional":true},{"reason":"Required for TrueType font support","package":"freetype","optional":true}],"imports":[{"note":"Direct import of Image without PIL prefix is incorrect.","wrong":"import Image","symbol":"Image","correct":"from PIL import Image"},{"note":"Direct import of ImageDraw without PIL prefix is incorrect.","wrong":"import ImageDraw","symbol":"ImageDraw","correct":"from PIL import ImageDraw"},{"note":"Direct import of ImageFont without PIL prefix is incorrect.","wrong":"import ImageFont","symbol":"ImageFont","correct":"from PIL import ImageFont"}],"quickstart":{"code":"from PIL import Image\n\n# Open an image file\nwith Image.open('example.jpg') as img:\n    # Display image\n    img.show()\n    # Save image in a different format\n    img.save('example.png')","lang":"python","description":"Open an image file, display it, and save it in a different format."},"warnings":[{"fix":"Upgrade to Python 3.10 or later.","message":"Dropped support for Python 3.9 in version 12.0.0.","severity":"breaking","affected_versions":"12.0.0 and later"},{"fix":"Upgrade FreeType to version 2.10.0 or later.","message":"Removed support for FreeType <= 2.9.0 in version 12.0.0.","severity":"breaking","affected_versions":"12.0.0 and later"},{"fix":"Use get_flattened_data() instead of getdata().","message":"Deprecated getdata() in favor of get_flattened_data() in version 12.1.0.","severity":"deprecated","affected_versions":"12.1.0 and later"},{"fix":"Use alternative methods for displaying images.","message":"Deprecated Image._show in version 12.0.0.","severity":"deprecated","affected_versions":"12.0.0 and later"},{"fix":"Check if _getexif() returns None before accessing its contents.","message":"Using _getexif() may return None if the image lacks EXIF data.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure the image file exists at the specified path and has appropriate read permissions.","message":"Image.open() raises FileNotFoundError if the specified image file does not exist at the given path.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Verify the image file path and ensure the file exists before calling `Image.open()`.","message":"Attempting to open a non-existent image file raises `FileNotFoundError`.","severity":"breaking","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T12:56:58.609Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"First, ensure Pillow is installed using `pip install Pillow`. Then, import the `Image` module using `from PIL import Image`.","cause":"This error occurs because the original Python Imaging Library (PIL) is outdated and has been superseded by Pillow. Developers often try to import the old 'PIL' package directly without installing Pillow, or they have Pillow installed but use an incorrect import statement.","error":"ModuleNotFoundError: No module named 'PIL'"},{"fix":"To fix this, avoid global imports like `from tkinter import *`. Instead, import specific components (e.g., `import tkinter as tk`) or explicitly import `Image` from Pillow as `from PIL import Image` and ensure correct casing (`Image.open()`).","cause":"This typically happens due to a namespace conflict, often when another library (like `tkinter` with `from tkinter import *`) also defines an 'Image' object, masking Pillow's `Image` module. It can also occur if `Image.open` is incorrectly cased as `Image.Open`.","error":"AttributeError: type object 'Image' has no attribute 'open'"},{"fix":"Verify the image file path is correct and the file exists. Ensure the image is not corrupted and is in a supported format. If applicable, close any other applications or processes that might be holding the file open. For web sources, ensure the data stream is a valid image.","cause":"This error means Pillow cannot recognize or open the specified image file. Common causes include an incorrect file path, a corrupted image file, an unsupported image format, or the file being locked by another process.","error":"PIL.UnidentifiedImageError: cannot identify image file"},{"fix":"Provide the full, absolute path to the `.ttf` or `.otf` font file. Ensure the font file exists at that location and that your program has read permissions. On some systems (like macOS), you might need to specify the exact system font directory.","cause":"This error frequently occurs when Pillow's `ImageFont.truetype()` function cannot locate the specified font file. This can be due to an incorrect font path, the font not being installed on the system, or permission issues preventing access to the font file.","error":"OSError: cannot open resource"},{"fix":"Exit the Python interpreter by typing `exit()` or pressing `Ctrl+D` (Unix/macOS) / `Ctrl+Z` then `Enter` (Windows), and then run the `pip install pillow` command in your operating system's command line interface (terminal/command prompt).","cause":"This error typically appears when a shell command like `pip install pillow` is executed inside the Python interactive interpreter (where you see `>>>` or `In [1]:`), instead of being run directly in the system's terminal or command prompt.","error":"SyntaxError: invalid syntax"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.05,"mem_mb":2.3,"disk_size":"37.3M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":2.3,"disk_size":"38M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.12,"mem_mb":2.6,"disk_size":"39.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.1,"mem_mb":2.6,"disk_size":"41M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":2.6,"disk_size":"31.4M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":2.6,"disk_size":"32M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":2.7,"disk_size":"31.1M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":2.5,"disk_size":"32M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.05,"mem_mb":2.3,"disk_size":"34.6M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.04,"mem_mb":2.3,"disk_size":"36M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}