A cross-platform tool to convert images into ascii art and print them on the console

Overview

ascii-image-converter

ascii-image-converter is a command-line tool that converts images into ascii art and prints them out onto the console. It is cross-platform so both Windows and Linux distributions are supported

Image formats currently supported:

  • PNG
  • JPEG/JPG
  • WEBP
  • BMP

Example (Source):

Example

ASCII Art:

Example


Installation

Go

For custom Go installs

go install github.com/TheZoraiz/[email protected]

For physically installing the binaries, download the executables from here, and follow the steps with respect to your OS.

Linux

Extract Executables.zip and open the "Linux" directory.

Now, open a terminal in the same directory and execute this command:

sudo cp ascii-image-converter /usr/local/bin/

Now you can use ascii-image-converter in the terminal. Execute "ascii-image-converter -h" for more details.

Windows

You will need to set an Environment Variable to the folder the ascii-image-converter.exe executable is placed in to be able to use it in the command prompt. Follow the instructions in case of confusion:

Extract Executables.zip and open the "Windows" folder. Copy the path to folder from the top of the file explorer.

  • In Search, search for and then select: System (Control Panel)
  • Click the Advanced System settings link.
  • Click Environment Variables. In the section User Variables find the Path environment variable and select it. Click "Edit".
  • In the Edit Environment Variable window, click "New" and then paste the path of the folder that you copied initially.
  • Afterwards, you can use it anywhere by typing "ascii-image-converter" in command prompt. Note: Make sure you restart the command prompt.

Usage

Note: Decrease font size or zoom out of terminal for maximum quality ascii art

To convert an image into ascii format, the usage is as follows:

ascii-image-converter [path to image]

Example

ascii-image-converter myImage.jpeg

Flags

--complex OR -c

Print the image with a wider array of ascii characters. Sometimes improves accuracy.

ascii-image-converter [path to image] -c
# Or
ascii-image-converter [path to image] --complex

--dimensions OR -d

Set the width and height of the printed ascii image in character lengths.

ascii-image-converter [path to image] -d ,
# Or
ascii-image-converter [path to image] --dimensions ,

Example:

ascii-image-converter [path to image] -d 100,30

--save OR -S

Save the image ascii art in a file ascii-image.txt in the same directory

ascii-image-converter [path to image] --save
# Or
ascii-image-converter [path to image] -S

You can combine commands as well

ascii-image-converter [path to image] -Scd 100,30

Packges used

github.com/spf13/viper

github.com/spf13/cobra

github.com/mitchellh/go-homedir

github.com/nathan-fiscaletti/consolesize-go

github.com/nfnt/resize

License

Apache-2.0

Comments
  • panic: runtime error: index out of range [0] with length 0

    panic: runtime error: index out of range [0] with length 0

    Hi :)

    Depending on which env i run it, it can result on:

    $ ascii-image-converter ./my_image.png
    
    panic: runtime error: index out of range [0] with length 0
    goroutine 1 [running]:
    github.com/TheZoraiz/ascii-image-converter/image_manipulation.ConvertToBrailleChars(0x0, 0x0, 0x0, 0x100, 0xff, 0xff, 0xff, 0x32, 0x0, 0x0, ...)
    	/home/zozu/Stuff/Projects/ascii-image-converter/image_manipulation/ascii_conversions.go:180 +0xa6c
    github.com/TheZoraiz/ascii-image-converter/aic_package.pathIsImage(0x7ffeae218883, 0xa, 0x0, 0x0, 0xc00000c300, 0x0, 0x0, 0x0, 0xc000010128, 0xc0000304f8, ...)
    	/home/zozu/Stuff/Projects/ascii-image-converter/aic_package/convert_image.go:54 +0x2ee
    github.com/TheZoraiz/ascii-image-converter/aic_package.Convert(0x7ffeae218883, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    	/home/zozu/Stuff/Projects/ascii-image-converter/aic_package/convert_root.go:157 +0x668
    github.com/TheZoraiz/ascii-image-converter/cmd.glob..func1(0xd26560, 0xc0000a48c0, 0x1, 0x5)
    	/home/zozu/Stuff/Projects/ascii-image-converter/cmd/root.go:97 +0x379
    github.com/spf13/cobra.(*Command).execute(0xd26560, 0xc000020250, 0x5, 0x5, 0xd26560, 0xc000020250)
    	/home/zozu/go/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0x2c2
    github.com/spf13/cobra.(*Command).ExecuteC(0xd26560, 0xc000000180, 0x200000003, 0xc000000180)
    	/home/zozu/go/pkg/mod/github.com/spf13/[email protected]/command.go:960 +0x375
    github.com/spf13/cobra.(*Command).Execute(...)
    	/home/zozu/go/pkg/mod/github.com/spf13/[email protected]/command.go:897
    github.com/TheZoraiz/ascii-image-converter/cmd.Execute()
    	/home/zozu/Stuff/Projects/ascii-image-converter/cmd/root.go:118 +0x31
    main.main()
    	/home/zozu/Stuff/Projects/ascii-image-converter/main.go:22 +0x25
    

    In this example, i launch it on a docker ubuntu 18 running inside a linux gitlab runner. Any idea ?

    bug enhancement 
    opened by lepapareil 13
  • Cannot open image in standard command prompt on Windows 10 21H1

    Cannot open image in standard command prompt on Windows 10 21H1

    when dragging and drop the image path on windows, it always gives out an error message, but when running cmd in admin mode, drag and drop simply won't work.

    bug 
    opened by PIndividual 6
  • macOS version

    macOS version

    πŸ‘‹ , first of all, thanks for this tool, it's awesome :)

    I was wondering why you don't include a macOS version.

    I was able to build ascii-image-converter locally (on Big Sur) without problems and since you are using goreleaser, it shouldn't take more than including darwin in the target goos.

    So, if there is no particular reason against it, i'd love to have a release for mac. I have little experience with go, but I'm happy to send an initial PR to get this going. Let me know!

    opened by xmarcos 6
  • Feature Request: bin piping support

    Feature Request: bin piping support

    It would be useful to be able quickly convert an image from stdin, like this:

    curl -sSL https:/foo.bar/baz.qux | ascii-image-converter
    

    or

    curl -sSL https:/foo.bar/baz.qux | ascii-image-converter -
    

    and can allow some more mixups like:

    curl -sSL https:/foo.bar/baz.qux | magick convert - png:- | ascii-image-converter
    

    or

    curl -sSL https:/foo.bar/baz.qux | magick convert - png:- | ascii-image-converter -
    

    I personally prefer doing it by default, but either one is fine by me 🀷

    opened by brian6932 5
  • The saved ascii art in txt, is not working properly

    The saved ascii art in txt, is not working properly

    When I use the command to save the ascii art in a txt file, it not displays properly, I think it's because the spaces or line breaks that the script don't do. Screenshot_5

    opened by Lufims 3
  • Wrong -C output

    Wrong -C output

    When I use the "-C" to display the output, the result is wired. The image saved using "--save-img" seems to be fine.

    the output displayed in the terminal. image

    the saved result leo-ascii-art

    opened by sicxu 3
  • Save output to ansi text file

    Save output to ansi text file

    Is there a way to save the output as an ansi text file? If I try to redirect output, it barfs during terminal size detection. If I also specify the output size with -d, it complains the terminal is too small.

    Update: I was able to capture the output using script but it would certainly be nice to have a proper save-as-ansi option.

    bug 
    opened by greenseeker 3
  • Brew deprecated arguments

    Brew deprecated arguments

    Gettings this error from brew:

    Warning: Calling bottle :unneeded is deprecated! There is no replacement.
    Please report this issue to the thezoraiz/ascii-image-converter tap (not Homebrew/brew or Homebrew/core):
      /opt/homebrew/Library/Taps/thezoraiz/homebrew-ascii-image-converter/ascii-image-converter.rb:10
    
    opened by jenslys 2
  • Used RGBA for save-bg flag

    Used RGBA for save-bg flag

    Hello !

    First of all, i would like to congratulate you on your work ! Your tool is very funny !

    I propose you to use RGBA instead of RGB for --save-bg flag. With my modifications, i can generate images (png) with a transparent background ( r, b, g, 0 ).

    Thank you !

    opened by jpagny 1
  • Clear ansi-colored output

    Clear ansi-colored output

    1. When characters in the row have the same color, will be better print escape code only once: \e[38;5;20mw\e[38;5;20mm -> \e[38;5;20mwm
    2. Use only space as invisible character, when background and text have same color: \e[38;5;0m<char> -> \e[38;5;0m

    Also, will be cool mixing --color and --color-bg. Maybe, in form --color=(fg|bg|both)

    opened by nadevko 1
  • Refactor root.go

    Refactor root.go

    Just going through and trying a little bit of refactoring to get a feel for the project. I did not see tests or lint rules but I did test manually for a bit, if there are concerns of specific flags or circumstances let me know.

    opened by miniscruff 1
  • --color-bg is not being applied when saving to a file

    --color-bg is not being applied when saving to a file

    When using --color-bg the saved image doesn't not have the background filled

    This is the output in the terminal.

    image

    This is the image saved. image-ascii-art.png image-ascii-art

    Original image: https://thesungod.xyz/V8mITZeX.jpeg

    I'm using version v1.11.0, installed via apt.

    opened by bydioeds 1
  • Docker image

    Docker image

    Hi,

    ascii-image-converter just created the perfect startup banner for our spring boot application. Thanks a bunch!

    As already noted, packaging is not trivial. A docker image for ascii-image-converter would make usage easier without the need for any local installation.

    I am attaching a Dockerfile that created a well usable image for me. Dockerfile.ascii-image-converter.txt

    (Usage: place in a working directory, such as an empty dir or the local git repo, execute docker build -t ascii-image-converter -f Dockerfile.ascii-image-converter.txt .. Usage of resulting image: docker run --rm -it ascii-image-converter <url>, or docker run -v $(pwd):/data --rm -it ascii-image-converter /data/<localfile>).

    Would you be interested in providing an "official" image on docker hub?

    If you prefer the file as a pull request, just give me a note.

    opened by bnutzer 1
  • Q. Debian packaging and/or launchpad?

    Q. Debian packaging and/or launchpad?

    I found this...

    https://www.reddit.com/r/golang/comments/o2ztb9/how_do_i_make_a_launchpad_ppa_for_a_go/

    ...and was wondering if you were still interested in making that work.

    opened by rubicks 1
Releases(v1.13.1)
Owner
Zoraiz Hassan
Idk what I'm doing, but it's definitely something.
Zoraiz Hassan
Convert images to computer generated art using delaunay triangulation.

β–² Triangle is a tool for generating triangulated image using delaunay triangulation. It takes a source image and converts it to an abstract image comp

Endre Simo 2k Nov 18, 2022
asciigrid is a Go package that implements decoder and encoder for the Esri ASCII grid format, also known as ARC/INFO ASCII GRID.

asciigrid asciigrid is a Go package that implements decoder and encoder for the Esri ASCII grid format, also known as ARC/INFO ASCII GRID. Install go

Ahmet Artu Yildirim 1 Jul 3, 2022
Human-friendly Go module that builds and prints directory trees using ASCII art

Human-friendly Go module that builds and prints directory trees using ASCII art.

Vadym Borodin 5 Oct 11, 2022
A simple javascript website that takes user input, queries a Go based backend which then creates ascii art and sends it back to the frontend

A simple javascript website that takes user input, queries a Go based backend which then creates ascii art and sends it back to the frontend. Finally the site displays the ascii art and offers the option to download as multiple file types.

null 0 Jan 7, 2022
Ascii-art-web

ASCII-ART-WEB Author: Alika96 How to run Run the following commands: For building an image: docker image build -t ascii-art-web-docker . For showing i

null 0 Dec 13, 2021
API for generate image to ASCII Art

ASCII API Generate ASCII art from image. You can try this API here: ascii.projec

Sh4yn 5 Jul 1, 2022
A command to output longified ascii art.

longify A command to output longified ascii art. Inspired by Tweet from @sheepla: https://twitter.com/Sheeeeepla/status/1522199846870196225 Installati

syumai 11 Sep 12, 2022
:foggy: Convert image to ASCII

?? Image2ascii Image2ASCII is a library that converts images into ASCII images and provides command-line tools for easy use. Installation go get githu

η§¦δΈ–ζˆ 715 Nov 21, 2022
Generate high-quality triangulated art from images.

An iterative algorithm to generate high quality triangulated images.

null 53 May 26, 2021
Resize upladed images to s3 bucket with given sizes, and uploades new images back to bucket

Features Resize upladed images to s3 bucket with given sizes, and uploades new images back to bucket Environment Variables IMAGE_SIZES - formax 200x20

null 1 Feb 2, 2022
Small project to convert images to grayscale

This is a small http server that will read images from a provided path, convert the image to gray, and then serve back the converted image Usage You c

Wolfgang E Sanyer 0 Nov 5, 2021
This command line converts .html file into .html with images embed.

embed-html This command line converts .html file into .html with images embed. Install > go get github.com/gonejack/embed-html Usage > embed-html *.ht

δΌšζœ‰ηŒ«ηš„ 1 Oct 6, 2022
Go cross-platform glfw library for creating an OpenGL context and receiving events.

glfw Package glfw experimentally provides a glfw-like API with desktop (via glfw) and browser (via HTML5 canvas) backends. It is used for creating a G

null 77 Sep 27, 2022
3D line art engine.

ln The 3D Line Art Engine ln is a vector-based 3D renderer written in Go. It is used to produce 2D vector graphics (think SVGs) depicting 3D scenes. T

Michael Fogleman 3.1k Nov 23, 2022
generativeart is a Go package to generate many kinds of generative art.

generativeart is a Go package to generate many kinds of generative art. The goal is to collect some excellent generative art (implemented in R or Processing), and rewrite them in Go again

null 818 Nov 28, 2022
Go cross-platform OpenGL bindings.

gl Package gl is a Go cross-platform binding for OpenGL, with an OpenGL ES 2-like API. It supports: macOS, Linux and Windows via OpenGL 2.1 backend, i

null 161 Oct 20, 2022
a tool to output images as RGB ANSI graphics on the terminal

imgcat Tool to output images in the terminal. Built with bubbletea install homebrew brew install trashhalo/homebrew-brews/imgcat prebuilt packages Pr

Stephen Solka 464 Nov 16, 2022
Fast and secure standalone server for resizing and converting remote images

imgproxy imgproxy is a fast and secure standalone server for resizing and converting remote images. The main principles of imgproxy are simplicity, sp

imgproxy 6.6k Nov 19, 2022
Read and write Netpbm images from Go programs

netpbm Introduction netpbm is a package for the Go programming language that implements image decoders and encoders for the Netpbm image formats. The

Scott Pakin 16 Jul 1, 2022