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

HEIF Image Thumbnail Analyzer

Build a Python tool that analyzes HEIF/HEIC images to extract and report information about embedded thumbnails.

Requirements

Create a script that:

  1. Accepts a HEIF/HEIC image file path as input
  2. Checks if the image contains embedded thumbnails
  3. Reports the number of thumbnails and their box sizes
  4. Extracts and saves each thumbnail as a separate image file

Input

  • A file path to a HEIF/HEIC image (e.g., photo.heic)

Output

The script should:

  1. Print thumbnail information to stdout in this format:
    • If thumbnails exist: Thumbnails found: <count> followed by Box sizes: [<size1>, <size2>, ...]
    • If no thumbnails: No thumbnails found
  2. Save each thumbnail as a PNG file with the naming pattern: thumbnail_<box_size>.png

Example Usage

python thumbnail_analyzer.py photo.heic

Expected output:

Thumbnails found: 2
Box sizes: [128, 256]
Saved: thumbnail_128.png
Saved: thumbnail_256.png

Test Cases

Test 1: Basic thumbnail extraction @test

Input file: test_image.heic (contains 2 thumbnails with box sizes 128 and 256)

Expected output:

Thumbnails found: 2
Box sizes: [128, 256]
Saved: thumbnail_128.png
Saved: thumbnail_256.png

File: thumbnail_analyzer.test.py

def test_thumbnail_extraction():
    # Create a test HEIF image with thumbnails
    import pillow_heif
    from PIL import Image

    # Create test image with thumbnails
    img = Image.new('RGB', (1000, 800), color='blue')
    heif = pillow_heif.from_pillow(img)
    heif.save('test_image.heic', thumbnails=[128, 256])

    # Run analyzer
    import thumbnail_analyzer
    result = thumbnail_analyzer.analyze('test_image.heic')

    assert result['count'] == 2
    assert 128 in result['box_sizes']
    assert 256 in result['box_sizes']

Test 2: Image without thumbnails @test

Input file: no_thumb.heic (HEIF image with no thumbnails)

Expected output:

No thumbnails found

File: thumbnail_analyzer.test.py

def test_no_thumbnails():
    import pillow_heif
    from PIL import Image

    # Create test image without thumbnails
    img = Image.new('RGB', (400, 300), color='red')
    heif = pillow_heif.from_pillow(img)
    heif.save('no_thumb.heic', thumbnails=[])

    # Run analyzer
    import thumbnail_analyzer
    result = thumbnail_analyzer.analyze('no_thumb.heic')

    assert result['count'] == 0

Dependencies { .dependencies }

pillow-heif { .dependency }

Provides HEIF/AVIF image format support for reading embedded thumbnails.

Pillow { .dependency }

Provides image processing capabilities for saving thumbnails as PNG files.