~dricottone/image2ascii

ref: 435f20fa3992a66d2d23870ff80400e8768ecacc image2ascii/README.md -rw-r--r-- 1.2 KiB
435f20fa — 秦世成 Update README.md 6 years ago
                                                                                
17a11481 qeesung
aabae983 qeesung
17a11481 qeesung
448b1ed9 qeesung
427a0f9e 秦世成
448b1ed9 qeesung
427a0f9e 秦世成
4baed2ab 秦世成
435f20fa 秦世成
d8483baf 秦世成
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# image2ascii

Convert image to ASCII

## installation

```bash
go get https://github.com/qeesung/image2ascii
```

## usage

```golang
package main

import (
	"fmt"
	"github.com/qeesung/image2ascii/convert"
	"image"
	_ "image/jpeg"
	_ "image/png"
	"log"
	"os"
)

func main() {
	f, err := os.Open("example/images/lufei.jpg")
	if err != nil {
		log.Fatal(err)
	}

	img, _, err := image.Decode(f)
	if err != nil {
		log.Fatal(err)
	}

	f.Close()
	asciiImage := convert.Image2ASCIIString(img, &convert.Options{
		Ratio: 0.2,
	})
	fmt.Print(asciiImage)
}
```

## example outputs

| Raw Image         | ASCII Image           |
| ------------- |:-------------:| 
| ![](https://raw.githubusercontent.com/qeesung/image2ascii/master/example/images/lufei.jpg)      | ![](https://raw.githubusercontent.com/qeesung/image2ascii/master/example/images/lufei_ascii.png) |
 ![](https://raw.githubusercontent.com/qeesung/image2ascii/master/example/images/pikaqiu.jpeg)      | ![](https://raw.githubusercontent.com/qeesung/image2ascii/master/example/images/pikaqiu_ascii.png) |
  ![](https://raw.githubusercontent.com/qeesung/image2ascii/master/example/images/baozou.jpg)      | ![](https://raw.githubusercontent.com/qeesung/image2ascii/master/example/images/baozou_ascii.png) |