Skip to content

Instantly share code, notes, and snippets.

@thatkookooguy
Created July 20, 2015 19:38
Show Gist options
  • Save thatkookooguy/0389d9609d5754d135a5 to your computer and use it in GitHub Desktop.
Save thatkookooguy/0389d9609d5754d135a5 to your computer and use it in GitHub Desktop.
open images in terminal in ascii art
open_image() {
term_width=`tput cols`
if [ -z "$1" ]; then
echo "${RED}ERROR${NC}: no parameter found"
elif [[ "$1" == *\.png ]]; then
curl $1 > pic.png && convert pic.png pic.jpg && jp2a --color --width=$term_width pic.jpg && rm pic.jpg pic.png
elif [[ "$1" == *\.jpg ]]; then
jp2a --color --width=$term_width $1
elif [[ "$1" == *\.gif ]]; then
curl $1 > pic.gif && convert pic.gif pic.jpg && jp2a --color --width=$term_width pic.jpg && rm pic.jpg pic.gif
elif [[ "$1" == *\.tif ]]; then
curl $1 > pic.tif && convert pic.tif pic.jpg && jp2a --color --width=$term_width pic.jpg && rm pic.jpg pic.tif
else
echo "${RED}ERROR${NC}: file format is not supported"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment