Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/perkovec/goscii
Image to ascii converter
https://github.com/perkovec/goscii
ascii ascii-art golang image
Last synced: about 2 months ago
JSON representation
Image to ascii converter
- Host: GitHub
- URL: https://github.com/perkovec/goscii
- Owner: Perkovec
- License: mit
- Created: 2024-10-13T19:32:16.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-10-16T22:47:01.000Z (4 months ago)
- Last Synced: 2024-11-07T03:23:30.743Z (3 months ago)
- Topics: ascii, ascii-art, golang, image
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GOSCII
library and cli for convert image to ASCII art
## Installation
```bash
# package
go get github.com/Perkovec/goscii# cli
go install github.com/Perkovec/goscii/cli/goscii
```## Roadmap
- [ ] (pkg) Add support for colors
- [ ] (cli) Add support for custom charset
- [ ] (pkg) Benchmarks## CLI usage
```bash
goscii [args]
```| Argument | Default | Description |
| -------- | ------- | ----------- |
| -h | | help |
| -i | | input image file |
| -c | 0 | output columns (0 - terminal width) |
| -r | 0 | output rows (0 - terminal height) |
| -f | contain | fit algorithm (contain, cover, height, width, fill) |## Package methods
### NewConverter
Create new converter instance with options
```go
package mainimport (
"fmt"
"github.com/Perkovec/goscii"
)func main() {
converter, err := goscii.NewConverter()
}
```### Convert
Convert image to ASCII art
```go
package mainimport (
"fmt"
"github.com/Perkovec/goscii"
"image"
"os"
_ "image/jpeg"
)func main() {
converter, err := goscii.NewConverter()
if err != nil {
panic(err)
}imageFile, err := getImageFromFilePath("image.jpg")
if err != nil {
panic(err)
}artRows := converter.Convert(imageFile)
for _, row := range artRows {
fmt.Println(row)
}
}func getImageFromFilePath(filePath string) (image.Image, error) {
f, err := os.Open(filePath)
if err != nil {
return nil, err
}
defer f.Close()
image, _, err := image.Decode(f)
return image, err
}
```