CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-asciimatics

A cross-platform package to replace curses (mouse/keyboard input & text colours/positioning) and create ASCII animations

81

1.32x
Overview
Eval results
Files

task.mdevals/scenario-7/

ASCII Art Image Converter

Build a Python script that converts image files to greyscale ASCII art and displays them in the terminal.

Requirements

The script should:

  • Accept an image file path as a command-line argument
  • Convert the image to greyscale ASCII art
  • Resize the ASCII output to fit within a maximum width of 80 characters
  • Print the ASCII art to the terminal (stdout)
  • Handle errors gracefully (e.g., file not found)

Implementation

@generates

Test Cases

  • Converting a simple PNG image produces ASCII art output as a multi-line string. @test
  • The ASCII output width does not exceed the specified maximum width. @test
  • When given a non-existent file path, the function raises a FileNotFoundError. @test

API

def convert_image_to_ascii(image_path: str, max_width: int = 80) -> str:
    """
    Convert an image file to greyscale ASCII art.

    Args:
        image_path: Path to the image file
        max_width: Maximum width of the output in characters (default: 80)

    Returns:
        String containing the ASCII art representation with newline characters

    Raises:
        FileNotFoundError: If image file doesn't exist
    """
    pass

Dependencies { .dependencies }

asciimatics { .dependency }

Provides image to ASCII conversion functionality.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-asciimatics

tile.json