Added WEBP and BMP support and added README.md
This commit is contained in:
parent
6559df4f20
commit
a77cfcd47d
|
|
@ -0,0 +1,80 @@
|
||||||
|
# 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
|
||||||
|
|
||||||
|
Currently, the tool supports PNG, JPEG/JPG, WEBP and BMP image formats
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
First download the executables from [here](https://github.com/TheZoraiz/ascii-image-converter/releases/tag/v1.1.1), 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
|
||||||
|
Extract Executables.zip and open the "Windows" folder. Copy the path to folder from the top of the file explorer and follow these instructions:
|
||||||
|
|
||||||
|
* 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
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### --dimensions OR -d
|
||||||
|
Set the width and height of the printed ascii image in character lengths.
|
||||||
|
```
|
||||||
|
ascii-image-converter [path to image] -d <width>,<height>
|
||||||
|
# Or
|
||||||
|
ascii-image-converter [path to image] --dimensions <width>,<height>
|
||||||
|
```
|
||||||
|
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
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
||||||
|
|
||||||
|
## License
|
||||||
|
[Apache-2.0](https://github.com/TheZoraiz/ascii-image-converter/blob/master/LICENSE)
|
||||||
10
cmd/root.go
10
cmd/root.go
|
|
@ -41,12 +41,10 @@ var (
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
if len(args) > 1 {
|
if len(args) > 1 {
|
||||||
fmt.Println("Error: Too many arguments")
|
cmd.Help()
|
||||||
fmt.Println("\nUsage:\n\tascii-image-converter [image path] [flags]")
|
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
} else if len(args) == 0 {
|
} else if len(args) == 0 {
|
||||||
fmt.Println("Error: Need an image")
|
cmd.Help()
|
||||||
fmt.Println("\nUsage:\n\tascii-image-converter [image path] [flags]")
|
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,8 +68,8 @@ var (
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if len(dims) > 0 && len(dims) != 2 {
|
if len(dims) > 0 && len(dims) != 2 {
|
||||||
fmt.Println("Error: Need two dimensions")
|
fmt.Println("Error: Need two dimensions\n")
|
||||||
fmt.Println("\nExample:\n\tascii-image-converter [image path] -d 100,30")
|
cmd.Help()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
1
go.mod
1
go.mod
|
|
@ -8,4 +8,5 @@ require (
|
||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||||
github.com/spf13/cobra v1.1.3
|
github.com/spf13/cobra v1.1.3
|
||||||
github.com/spf13/viper v1.7.1
|
github.com/spf13/viper v1.7.1
|
||||||
|
golang.org/x/image v0.0.0-20210504121937-7319ad40d33e // indirect
|
||||||
)
|
)
|
||||||
|
|
|
||||||
2
go.sum
2
go.sum
|
|
@ -205,6 +205,8 @@ golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm0
|
||||||
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
|
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
|
||||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
|
golang.org/x/image v0.0.0-20210504121937-7319ad40d33e h1:PzJMNfFQx+QO9hrC1GwZ4BoPGeNGhfeQEgcQFArEjPk=
|
||||||
|
golang.org/x/image v0.0.0-20210504121937-7319ad40d33e/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ import (
|
||||||
_ "image/jpeg"
|
_ "image/jpeg"
|
||||||
_ "image/png"
|
_ "image/png"
|
||||||
|
|
||||||
|
_ "golang.org/x/image/bmp"
|
||||||
|
_ "golang.org/x/image/webp"
|
||||||
|
|
||||||
"github.com/nathan-fiscaletti/consolesize-go"
|
"github.com/nathan-fiscaletti/consolesize-go"
|
||||||
"github.com/nfnt/resize"
|
"github.com/nfnt/resize"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue