Skip to main content

imgcat as Python API and CLI

Project description

imgcat

pypi Build Status license

The imgcat CLI, written in Python (and Python API, too).

It works with iTerm2, and even inside tmux.

Installation and Usage

pip install imgcat

Command-line interface (similar to iTerm2's imgcat):

$ imgcat local_image.png
$ imgcat a.png b.png c.png
$ cat from_stdin.gif | imgcat

# height is 10 lines
$ imgcat a.png --height 10

Python API:

>>> from imgcat import imgcat

# from the content of image (e.g. buffer in python3, str in python2)
>>> imgcat(open("./local_image.png"))

# or numpy arrays!
>>> im = skimage.data.chelsea()   # [300, 451, 3] ndarray, dtype=uint8
>>> imgcat(im, height=7)

# matplotlib, PIL.Image, etc.
>>> imgcat(Image.fromarray(im))

>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots(); ax.plot([1, 2, 3, 4, 5])
>>> imgcat(fig)

Matplotlib Backend: module://imgcat

MPLBACKEND="module://imgcat" python draw_matplotlib.py
>>> import matplotlib
>>> matplotlib.use("module://imgcat")

>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> ax.text(0.5, 0.5, "Hello World!");
>>> fig.show()
# an image shall be displayed on your terminal!

IPython magic (works both in terminal and notebook)

%load_ext imgcat
%imgcat skimage.data.chelsea()

Notes

Related Projects

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imgcat-0.5.0.tar.gz (9.9 kB view details)

Uploaded Source

File details

Details for the file imgcat-0.5.0.tar.gz.

File metadata

  • Download URL: imgcat-0.5.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

File hashes

Hashes for imgcat-0.5.0.tar.gz
Algorithm Hash digest
SHA256 a6261bd3c766b1761a146d6e7209fb54620691b31057d0c050b96a761293cfe0
MD5 ef2fb1f2c9462314f2579107cee36475
BLAKE2b-256 d4561c3277dd00e8014e9499d8f654f7179d84edf4a07bf4b7932410625057aa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page