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-9/

HEIF Image Cache System

Build a simple cache system that stores HEIF image data for quick retrieval.

Requirements

Create a Python module that implements a cache for HEIF images using file-based serialization. The cache should allow storing and retrieving HEIF images efficiently.

CacheManager Class

Implement a CacheManager class with the following functionality:

  1. Initialize with a cache directory path
  2. Store HEIF image data with a unique key
  3. Retrieve cached HEIF image data by key
  4. Check if a key exists in the cache
  5. Clear all cached items

The cache should preserve:

  • All image data in HEIF containers
  • Multiple images within HEIF files
  • Image metadata (EXIF, XMP, etc.)
  • Image properties (size, mode, etc.)

Test Cases

  • Store a HEIF image, retrieve it, and verify image data is identical @test
  • Store a multi-image HEIF container, retrieve it, and verify all images are preserved @test
  • Store a HEIF image with EXIF metadata, retrieve it, and verify metadata is preserved @test
  • Check that a non-existent key returns None @test

Implementation

@generates

API

class CacheManager:
    """Manages cached HEIF images using serialization."""

    def __init__(self, cache_dir: str):
        """Initialize cache manager with a directory path.

        Args:
            cache_dir: Path to directory for storing cache files
        """
        pass

    def store(self, key: str, heif_file) -> None:
        """Store a HEIF file in the cache.

        Args:
            key: Unique identifier for the cached item
            heif_file: HeifFile object to cache
        """
        pass

    def retrieve(self, key: str):
        """Retrieve a HEIF file from the cache.

        Args:
            key: Unique identifier for the cached item

        Returns:
            HeifFile object if found, None otherwise
        """
        pass

    def exists(self, key: str) -> bool:
        """Check if a key exists in the cache.

        Args:
            key: Unique identifier to check

        Returns:
            True if key exists, False otherwise
        """
        pass

    def clear(self) -> None:
        """Remove all cached items."""
        pass

Dependencies { .dependencies }

pillow-heif { .dependency }

Provides HEIF image format support with serialization capabilities.