All Projects → google → Gif For Cli

google / Gif For Cli

Licence: apache-2.0
opensource.googleblog.com/2018/06/tenor-gif-for-cli.html

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Gif For Cli

Dry Cli
General purpose Command Line Interface (CLI) framework for Ruby
Stars: ✭ 210 (-92.42%)
Mutual labels:  cli, command-line
Kmdr Cli
🧠 The CLI tool for learning commands from your terminal
Stars: ✭ 218 (-92.14%)
Mutual labels:  cli, command-line
Givegif
GIFs on the command line
Stars: ✭ 212 (-92.35%)
Mutual labels:  cli, gifs
Facebook Dl
📼 Very minimal Facebook downloader written in 28 lines of Python code (not including comments and blank spaces)
Stars: ✭ 207 (-92.53%)
Mutual labels:  cli, command-line
Websocat
Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions
Stars: ✭ 3,477 (+25.43%)
Mutual labels:  cli, command-line
Stonky
A command line dashboard for monitoring stocks
Stars: ✭ 208 (-92.5%)
Mutual labels:  cli, command-line
Webpack Command
[DEPRECATED] Lightweight, modular, and opinionated webpack CLI that provides a superior experience
Stars: ✭ 218 (-92.14%)
Mutual labels:  cli, command-line
Survey
A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
Stars: ✭ 2,843 (+2.56%)
Mutual labels:  cli, command-line
Go Termd
Package termd provides terminal markdown rendering, with code block syntax highlighting support.
Stars: ✭ 223 (-91.96%)
Mutual labels:  cli, command-line
Klog
A plain-text file format and command line tool for time tracking
Stars: ✭ 222 (-91.99%)
Mutual labels:  cli, command-line
Saldl
A lightweight well-featured CLI downloader optimized for speed and early preview.
Stars: ✭ 203 (-92.68%)
Mutual labels:  cli, command-line
Jquery.terminal
jQuery Terminal Emulator - JavaScript library for creating web-based terminals with custom commands
Stars: ✭ 2,623 (-5.38%)
Mutual labels:  cli, command-line
Ascii
👾 ASCII Roulette :: ascii art video chat on the cli
Stars: ✭ 202 (-92.71%)
Mutual labels:  cli, command-line
Laravel Zero
A PHP framework for console artisans
Stars: ✭ 2,821 (+1.77%)
Mutual labels:  cli, command-line
Miniserve
🌟 For when you really just want to serve some files over HTTP right now!
Stars: ✭ 2,894 (+4.4%)
Mutual labels:  cli, command-line
Csview
📠 A high performance csv viewer with cjk/emoji support.
Stars: ✭ 208 (-92.5%)
Mutual labels:  cli, command-line
Zoxide
A smarter cd command. Supports all major shells.
Stars: ✭ 4,422 (+59.52%)
Mutual labels:  cli, command-line
Askgit
Query git repositories with SQL. Generate reports, perform status checks, analyze codebases. 🔍 📊
Stars: ✭ 2,707 (-2.34%)
Mutual labels:  cli, command-line
Pi Timelapse
Time-lapse app for Raspberry Pi computers.
Stars: ✭ 220 (-92.06%)
Mutual labels:  gif, gifs
Gitlab Cli
Create a merge request from command line in gitlab
Stars: ✭ 224 (-91.92%)
Mutual labels:  cli, command-line

gif-for-cli logo

Takes in a GIF, short video, or a query to the Tenor GIF API and converts it to animated ASCII art. Animation and color support are performed using ANSI escape sequences.

Example use cases:

  • run gif-for-cli in your .bashrc or .profile to get an animated ASCII art image as your MOTD!
  • git hooks ;)

This script will automatically detect how many colors the current terminal uses and display the correct version:

Original GIF No Colors Supported 256 Colors Supported 256 Colors Supported (with foreground and background colors) Truecolor Supported
Original GIF No Color Animated ASCII Art 256 Colors Animated ASCII Art 256 FG/BG Colors Animated ASCII Art Truecolor Animated ASCII Art

Installation

Requires Python 3 (with setuptools and pip), zlib, libjpeg, and ffmpeg, other dependencies are installed by setup.py.

Install dependencies:

# Debian based distros
sudo apt-get install ffmpeg zlib* libjpeg* python3-setuptools
# Mac
brew install ffmpeg zlib libjpeg python

Your Python environment may need these installation tools:

sudo easy_install3 pip
# This should enable a pre-built Pillow wheel to be installed, otherwise
# you may need to install Python, zlib, and libjpeg development libraries
# so Pillow can compile from source.
pip3 install --user wheel

Install gif-for-cli:

Install from PyPI:

pip3 install --user gif-for-cli

Or download this repo and run:

python3 setup.py install --user

The gif-for-cli command will likely be installed into ~/.local/bin or similar, you may need to put that directory in your $PATH by adding this to your .profile:

# Linux
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi
# Mac, adjust for Python version
if [ -d "$HOME/Library/Python/3.6/bin/" ] ; then
    PATH="$HOME/Library/Python/3.6/bin/:$PATH"
fi

Usage

File/URL

gif-for-cli path/to/some.gif
gif-for-cli http://example.com/foo.gif
gif-for-cli http://example.com/foo.mp4

Executing as a Python module is also supported:

python3 -m gif_for_cli path/to/some.gif

Query Tenor's GIF API

Queries to Tenor's GIF API can also be performed:

# get current top trending GIF
gif-for-cli

# get top GIF for "Happy Birthday"
gif-for-cli "Happy Birthday"

# get GIF with ID #11699608
# browse https://tenor.com/ for more!
gif-for-cli 11699608
gif-for-cli https://tenor.com/view/rob-delaney-peter-deadpool-deadpool2-untitled-deadpool-sequel-gif-11699608

Override display mode

gif-for-cli --display-mode=nocolor 11699608
gif-for-cli --display-mode=256 11699608
gif-for-cli --display-mode=256fgbg 11699608
gif-for-cli --display-mode=truecolor 11699608

Change max width/height

The default number of rows and columns may be too large and result in line wrapping. If you know your terminal size, you can control the output size with the following options:

gif-for-cli --rows 10 --cols 100 11699608

Set to current terminal size:

gif-for-cli --rows `tput lines` --cols `tput cols` 11699608

Note: Generated ASCII art is cached based on the number of rows and columns, so running that command after resizing your terminal window will likely result in the ASCII Art being regenerated.

Loop forever

gif-for-cli -l 0 11699608

Use CTRL + c to exit.

Export/Share

Want to share your generated ASCII Art outside a CLI env (e.g. social media)?

gif-for-cli 11699608 --export=foo.gif

Help

See more generation/display options:

gif-for-cli --help

About Tenor

Tenor is the API that delivers the most relevant GIFs for any application, anywhere in the world. We are the preferred choice for communication products of all types and the fastest growing GIF service on the market.

Check out our API Docs: https://tenor.com/gifapi

Testing

python3 -m unittest discover

With coverage:

coverage run --source gif_for_cli -m unittest discover
coverage report -m

Development

To reuse the shared Git hooks in this repo, run:

git config core.hooksPath git-hooks

Troubleshooting

If you get an error like the following:

-bash: gif-for-cli: command not found

Chances are gif-for-cli was installed in a location not on your PATH. This can happen if running gif-for-cli in your .bashrc, but it was installed into ~/.local/bin, and that directory hasn't been added to your PATH. You can either specify the full path to gif-for-cli to run it, or add its location to your $PATH.

Some of our Favorites

gif-for-cli 10988977
gif-for-cli 5863633
gif-for-cli 5437241

Module Usage

To add gifs to your cli tool include gif-for-cli import and call execute.

import os
import sys

from gif_for_cli.execute import execute

execute(os.environ,
    ["https://tenor.com/view/yay-pokemon-pikachu-gif-8081211"],
    sys.stdout)

Disclaimer

This is not an officially supported Google product.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].