tessl install tessl/pypi-pillow-heif@1.1.0Python interface for libheif library providing HEIF/AVIF image processing with both standalone and Pillow plugin capabilities
Agent Success
Agent success rate when using this tile
94%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.45x
Baseline
Agent success rate without this tile
65%
Build a command-line tool that extracts information from HEIF/AVIF image files and generates a summary report. The tool should validate file formats, read image properties, and handle multi-image containers.
Your tool should:
The tool should accept a file path as a command-line argument and output a formatted report to stdout.
Example output format:
File: image.heic
Format: Supported HEIF/AVIF
MIME Type: image/heic
Primary Image: #0
- Size: 1920x1080
- Mode: RGB
Total Images: 1For multi-image files:
File: burst.heic
Format: Supported HEIF/AVIF
MIME Type: image/heic
Primary Image: #2
- Size: 4032x3024
- Mode: RGB
Total Images: 5
All Images:
Image #0: 4032x3024, RGB
Image #1: 4032x3024, RGB
Image #2: 4032x3024, RGB (primary)
Image #3: 4032x3024, RGB
Image #4: 4032x3024, RGB@generates
def is_heif_supported(filepath: str) -> bool:
"""
Check if the given file is a supported HEIF/AVIF format.
Parameters:
- filepath: str, path to the file to check
Returns:
bool: True if supported, False otherwise
"""
def extract_image_info(filepath: str) -> dict:
"""
Extract information from a HEIF/AVIF file.
Parameters:
- filepath: str, path to the HEIF/AVIF file
Returns:
dict: Dictionary containing:
- mimetype: str, MIME type of the file
- primary_index: int, index of primary image
- total_images: int, total number of images
- images: list of dicts, each containing:
- index: int
- size: tuple (width, height)
- mode: str
Raises:
IOError: If file cannot be read or is invalid
"""
def format_report(file_info: dict, filepath: str) -> str:
"""
Format extracted information into a readable report.
Parameters:
- file_info: dict, information extracted from extract_image_info()
- filepath: str, original file path
Returns:
str: Formatted report string
"""
def main():
"""
Main entry point for the command-line tool.
Reads filepath from command-line arguments and prints report.
"""Provides HEIF/AVIF image reading and format detection capabilities.
@satisfied-by