Skip to main content

Term-Image

Display images in the terminal with Python

📖 Docs ║ 🏫 Tutorial

Documentation Status

Contents

⚠️ NOTICE!!! ⚠️

The image viewer (CLI and TUI) has been moved to termvisage.

Installation

Requirements

Steps

The latest stable version can be installed from PyPI with:

pip install term-image

The development version can be installed with:

pip install git+https://github.com/AnonymouX47/term-image.git

Supported Terminal Emulators

See here for a list of tested terminal emulators.

If you've tested this library on any other terminal emulator that meets the requirements for any of the render styles, please mention the name (and version) in a new thread under this discussion.

Also, if you have any issue with terminal support, you may report or check information about it in the discussion linked above.

Features

  • Multiple image formats (basically all formats supported by PIL.Image.open())
  • Multiple image source types: PIL image instance, local file, URL
  • Multiple image render styles (with automatic support detection)
  • Support for multiple terminal graphics protocols: Kitty, iTerm2
    • Exposes various features of the protocols
  • Transparency support (with multiple options)
  • Animated image support (including transparent ones)
    • Multiple formats: GIF, WEBP, APNG (and possibly more)
    • Fully controllable iteration over rendered frames of animated images
    • Image animation with multiple parameters
  • Integration into various TUI / terminal-based output libraries.
  • Terminal size awareness
  • Automatic and manual image sizing
  • Horizontal and vertical alignment
  • Automatic and manual font ratio adjustment (to preserve image aspect ratio)
  • and more... 😁

Demo

Check out this image viewer based on this library.

Quick Start

Creating an instance

  1. Initialize with a file path:

    from term_image.image import from_file
    
    image = from_file("path/to/image.png")
    
  2. Initialize with a URL:

    from term_image.image import from_url
    
    image = from_url("https://www.example.com/image.png")
    
  3. Initialize with a PIL (Pillow) image instance:

    from PIL import Image
    from term_image.image import AutoImage
    
    img = Image.open("path/to/image.png")
    image = AutoImage(img)
    

Drawing/Displaying an Image

There are two basic ways to draw an image to the terminal screen:

  1. Using the draw() method:

    image.draw()
    

    NOTE: draw() has various parameters for render formatting.

  2. Using print() with an image render output:

    print(image)  # without formatting
    # OR
    print(f"{image:>200.^100#ffffff}")  # with formatting
    

For animated images, only the former animates the output, the latter only draws the current frame.

See the tutorial for a more detailed introduction.

Usage

🚧 Under Construction - There will most likely be incompatible changes between minor versions of version zero!

If you want to use this library in a project while it's still on version zero, ensure you pin the dependency to a specific minor version e.g >=0.4,<0.5.

See the docs for the User Guide and API Reference.

Contribution

Please read through the guidelines.

For code contributions, you should also check out the Planned Features. If you wish to work on any of the listed features/improvements, please click on the linked issue or go through the issues section and join in on an ongoing discussion about the task or create a new issue if one hasn't been created yet, so that the implementation can be discussed.

Hint: You can filter issues by label or simply search using the features's description.

Thanks! 💓

Planned Features

See here.

Known Issues

See here.

FAQs

See the FAQs section of the docs.

Credits

The following projects have been (and are still) crucial to the development of this project:

The logo was composed using resource(s) from the following source(s):

Sponsor This Project

Buy Me A Coffee

Any amount will go a long way in aiding the progress and development of this project. Thank you! 💓

Release files for term-image 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for term-image 0.7.0
File Size Uploaded
term-image-0.7.0.tar.gz 61.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for term-image 0.7.0
File Interpreter ABI Platform
term_image-0.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 123.0 kB

Release files / term-image-0.7.0.tar.gz

Download URL term-image-0.7.0.tar.gz
Size 61.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d62d85b62b58a90576b2dc22478aeee7eb71bfac169862a0abc94c9f494c8b0c
BLAKE2b-256 checksum
How to use checksums
f259019a0ca982be3e6d686b9c58a72ae26333b69f8a312ea6edcbefef57279b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.10

Release files / term_image-0.7.0-py3-none-any.whl

Download URL term_image-0.7.0-py3-none-any.whl
Size 62.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7da30c2a9018de037da565d4bd65a348eaa8ccfee6de0b2bb1fd6d2506e716f4
BLAKE2b-256 checksum
How to use checksums
0aa8a63a445d2c75bcbb64fec3afe708b217cea64fa19c764381a67e8a824a26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.10

Release history Release notifications | RSS feed

0.7.2

2 release files

0.7.1

2 release files

This release

0.7.0 This release

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page