or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pillow-heif@1.1.x
tile.json

tessl/pypi-pillow-heif

tessl install tessl/pypi-pillow-heif@1.1.0

Python 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%

task.mdevals/scenario-3/

HEIF Image Metadata Extractor

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.

Requirements

Your tool should:

  1. Accept a file path as input and validate that it's a supported HEIF/AVIF format before processing
  2. Extract and display basic image properties including dimensions, color mode, and MIME type
  3. For multi-image containers, display information about all images in the file, including which image is the primary one
  4. Handle file access errors gracefully and provide clear error messages

Input/Output Format

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: 1

For 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

Test Cases

  • When given a valid HEIF file with a single image, the tool outputs the correct dimensions and color mode @test
  • When given a valid HEIF file with multiple images, the tool lists all images and correctly identifies the primary image @test
  • When given a file that is not a HEIF/AVIF format, the tool reports that the format is unsupported @test

Implementation

@generates

API

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.
    """

Dependencies { .dependencies }

pillow-heif { .dependency }

Provides HEIF/AVIF image reading and format detection capabilities.

@satisfied-by