Skip to content

Instantly share code, notes, and snippets.

@alephalpha0
Created October 26, 2020 21:56
Show Gist options
  • Save alephalpha0/d34975eb72e466b842ba8c067d6d4b18 to your computer and use it in GitHub Desktop.
Save alephalpha0/d34975eb72e466b842ba8c067d6d4b18 to your computer and use it in GitHub Desktop.
Im messing about with images on terminal. This is just for future reference.

Using ImageMagick via CLI is esoteric but some google-fu sorted me out.

convert (originalfile) -resize ##% (outputfile) will resize an image by the percentage given. Better than using -scale as it keeps the image quality up. Replace ##% with HxW to make the image resize into dimensions that best fit H or W. eg, a 1024x768 original ran through -resize 80x80 will have width of 80 and height within ratio.

Converting from one imgage type to the next is simple as well. convert png myjpeg.jpg will convert myjpeg.jpg into a png.

Using jp2a as a neat tool to output images via ascii and ansi color codes into the terminal is fun and entertaining, but fleeting.

If I want to save the output for future use and display, I have two options. The first outputs html via jp2a . jp2a --zoom-term --colors --html (originalfile) > newfile.html will put the HTML output from jp2a into an html file. If, instead, I want to save the ansi codes and ascii decorations without formatting into html, I can simply pipe the output of the command jp2a ---colors --zoom-term (originalfile) > newfile.txt and be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment