Skip to main content

imgcat as Python API and CLI

Project description

`imgcat`
========

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

<img src="./screenshot.png" width="640" height="520" />

It works with [iTerm2](https://www.iterm2.com/documentation-images.html), and even inside tmux.


Installation and Usage
----------------------

```
pip install imgcat
```

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

```bash
$ 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:

```python
>>> 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)
```

Notes
-----

* Currently tmux 2.5+ cannot display big images. Use tmux <= 2.4 or run outside tmux.
* TODO: General platform/emulator support (introduce multiple backends)


Related Projects
----------------

* Original implementation: [imgcat][iTerm2_imgcat] from iTerm2 (limited tmux support)
* A modified version with better tmux support by [Eric Dobson](https://gitlab.com/gnachman/iterm2/issues/3898#note_14097715) and [@krtx](https://gist.github.com/krtx/533d33d6cc49ecbbb8fab0ae871059ec)
* Node.js: [term-img](https://github.com/sindresorhus/term-img) (no tmux support)
* Go: [iterm2-imagetools](https://github.com/olivere/iterm2-imagetools) (no tmux support)


[iTerm2_imgcat]: https://github.com/gnachman/iTerm2/blob/master/tests/imgcat


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.1.1.tar.gz (6.3 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: imgcat-0.1.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.6.5

File hashes

Hashes for imgcat-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0c3efd3c4d72318c12a3a5b678a54f5187fb588c2bff82877aa7b56d04c1e800
MD5 093221e6b18ea8c668db99e165b19748
BLAKE2b-256 4783faf341343184cc762554a9d04d631bb7168fadfaf53be9872f815d040315

See more details on using hashes here.

Supported by

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