{"library":"pyheif","title":"PyHEIF","description":"PyHEIF is a Python 3.6+ interface to the `libheif` C library, enabling decoding of HEIF (High Efficiency Image Format) and HEIC images. It facilitates converting HEIF/HEIC images to raw pixel data, commonly used with libraries like Pillow. The current version is 0.8.0, with releases typically tied to Python version support and `libheif` updates, as well as new features.","language":"python","status":"active","last_verified":"Mon May 18","install":{"commands":["pip install pyheif"],"cli":null},"imports":["from pyheif import read"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pyheif\nfrom PIL import Image\nimport os\n\n# This example assumes you have an 'example.heic' file.\n# For a real scenario, replace 'example.heic' with your HEIF/HEIC file path.\n# If you don't have one, you might need to create a dummy file or download one.\n# For local testing without a file, this would fail, so ensure file exists.\n# HEIF files often come from iPhones or other modern cameras.\n\ntry:\n    # Read the HEIF file. This can return HeifFile or HeifContainer.\n    heif_object = pyheif.read(\"example.heic\")\n\n    if isinstance(heif_object, pyheif.HeifContainer):\n        # Handle multiple images (e.g., burst photos, depth maps)\n        print(f\"File contains {len(heif_object.heif_files)} images.\")\n        primary_image = heif_object.primary_image\n    else:\n        # Single image file\n        primary_image = heif_object\n\n    # Convert to Pillow Image\n    # The 'raw' decoder requires mode and stride matching the heif_file output\n    pillow_image = Image.frombytes(\n        primary_image.mode,\n        (primary_image.width, primary_image.height),\n        primary_image.data,\n        \"raw\",\n        primary_image.mode,\n        primary_image.stride,\n    )\n\n    # Save the image as PNG\n    output_path = \"output_image.png\"\n    pillow_image.save(output_path, \"PNG\")\n    print(f\"Successfully decoded and saved image to {output_path}\")\n\nexcept FileNotFoundError:\n    print(\"Error: 'example.heic' not found. Please create or provide a valid HEIC file path.\")\nexcept pyheif.error.HeifError as e:\n    print(f\"Error decoding HEIF file: {e}\")\nexcept ImportError:\n    print(\"Error: Pillow not installed. Please install with 'pip install Pillow'.\")\n","lang":"python","description":"This quickstart demonstrates how to decode a HEIF/HEIC image using `pyheif` and convert it into a Pillow `Image` object. It also shows how to handle both single-image and multi-image HEIF files introduced in `pyheif` 0.7.0. The decoded image is then saved as a PNG file. Remember to replace 'example.heic' with a path to a valid HEIC file.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-18","installed_version":"0.8.0","pypi_latest":"0.8.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":40,"avg_install_s":2,"avg_import_s":0.02,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pyheif","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pyheif","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2,"import_time_s":0.01,"mem_mb":1,"disk_size":"37M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pyheif","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pyheif","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2,"import_time_s":0.02,"mem_mb":1,"disk_size":"39M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pyheif","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pyheif","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.8,"import_time_s":0.02,"mem_mb":0.8,"disk_size":"31M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pyheif","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pyheif","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.3,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pyheif","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pyheif","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.4,"import_time_s":0.02,"mem_mb":1,"disk_size":"37M"}]}}