Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frnsys/termimg
render raster images to terminal
https://github.com/frnsys/termimg
Last synced: 3 months ago
JSON representation
render raster images to terminal
- Host: GitHub
- URL: https://github.com/frnsys/termimg
- Owner: frnsys
- Created: 2016-03-07T04:44:31.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-03-07T17:49:08.000Z (over 8 years ago)
- Last Synced: 2024-06-11T17:29:40.262Z (5 months ago)
- Language: Python
- Size: 1.23 MB
- Stars: 14
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
- starred-awesome - termimg - render raster images to terminal (Python)
README
This module provides a function, `show_image`, which lets you render an image (without fumbly ASCII representations) to a supported X11 terminal (such as `urxvt`).
This requires `w3mimgdisplay` (this is usually available in package managers, e.g. `apt-get install w3m-img`).
Installation:
pip install -U termimg
Usage:
from termimg import render_image
render_image('~/downloads/masashi_wakui.png', margin=2)This is all based on [research by z3bra](http://blog.z3bra.org/2014/01/images-in-terminal.html).
Arguments to `render_image`:
img_path: path to image to display
x: x position, in pixels (top-left anchor)
y: y position, in pixels (top-left anchor)
margin: margin around image, in terminal rows/columns
scale_to_fit: scale image automatically to fit within available space (taking margins into account)
keep_aspect: maintain aspect ratio if only one of width or height is specified
width: width, in pixels, image should be rendered at
height: height, in pixels, image should be rendered at
x_offset: x offset, in pixels
y_offset: y offset, in pixels
bin: path to the `w3mimgdisplay` binary# Example
![`termimg` example](shot.png)
Photo by [Masashi Wakui](https://www.flickr.com/photos/megane_wakui/).
# License
The MIT License (MIT)
Copyright (c) 2016 Francis Tseng
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.