Skip to content

1-ashraful-islam/image2ascii

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GO Package for Image to ASCII in color

This is a simple package that converts an image to ASCII in color that can be printed to the terminal. It was created by pair programming with GPT4 as I needed something simple, yet beautiful ascii art generator for another project.

Since the package returns the ASCII image as a slice of strings, you can easily print it to the terminal or save it to a file. It is also possible to have your own texts printed either to the right or left of the image by appending the text to the slice of strings.

Inspiration for this package came from image-to-ascii-art ascii-image-converter

Features

  • Convert an image to ASCII in color
  • Maintains aspect ratio of the original image
  • Returns the ASCII image as a slice of strings
  • Provides a loading function for image paths

Installation

If you want to use this package in your go project, you can install it using the following command:

go get github.com/1-ashraful-islam/image2ascii

Usage

package main

import (
  "fmt"

  im2ascii "github.com/1-ashraful-islam/image-to-ascii"
)

func main() {
  //load image
  img, err := im2ascii.LoadImage("path/to/image.jpg")
  if err != nil {
    fmt.Println(err)
    return
  }
  //create ascii image
  asciiImage, err := im2ascii.CreateASCIIImage(img, 80, 80)
  if err != nil {
    fmt.Println(err)
    return
  }
  //print ascii image
  for _, line := range asciiImage {
    fmt.Println(line)
  }
}

Testing

To run the tests, you can use the following command:

go test ./... -v -cover

Example output

Original Image ASCII Image
Pikachu Pikachu ASCII
Mona Lisa Mona Lisa ASCII
Toy Story Toy Story ASCII

Original Images (left column) used in the examples are not property of the author and were taken from the internet. They are used for educational purposes only.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages