Updated README.md and minor logging corrections

This commit is contained in:
Zoraiz Hassan
2022-05-31 23:31:20 +05:00
parent 62789959c8
commit 17a7ef5c49
3 changed files with 7 additions and 7 deletions

View File

@@ -404,7 +404,7 @@ Saves the passed GIF as an ascii art GIF with the name `<image-name>-ascii-art.g
> **Note:** This flag will be ignored if `--save-img` or `--save-gif` flags are not set
This flag takes an RGBA value that sets the background color in saved png and gif files.
This flag takes an RGBA value that sets the background color in saved png and gif files. The fourth value (alpha value) is the measure of background opacity ranging between 0 and 100.
```
ascii-image-converter [image paths/urls] -s . --save-bg 255,255,255,100 # For white background

View File

@@ -58,7 +58,7 @@ var (
rootCmd = &cobra.Command{
Use: "ascii-image-converter [image paths/urls]",
Short: "Converts images and gifs into ascii art",
Version: "1.11.0",
Version: "1.12.0",
Long: "This tool converts images into ascii art and prints them on the terminal.\nFurther configuration can be managed with flags.",
// Not RunE since help text is getting larger and seeing it for every error impacts user experience
@@ -86,7 +86,7 @@ var (
Full: full,
FontFilePath: fontFile,
FontColor: [3]int{fontColor[0], fontColor[1], fontColor[2]},
SaveBackgroundColor: [4]int{saveBgColor[0], saveBgColor[1], saveBgColor[2],saveBgColor[3]},
SaveBackgroundColor: [4]int{saveBgColor[0], saveBgColor[1], saveBgColor[2], saveBgColor[3]},
Braille: braille,
Threshold: threshold,
Dither: dither,
@@ -149,7 +149,7 @@ func init() {
rootCmd.PersistentFlags().StringVarP(&saveImagePath, "save-img", "s", "", "Save ascii art as a .png file\nFormat: <image-name>-ascii-art.png\nImage will be saved in passed path\n(pass . for current directory)\n")
rootCmd.PersistentFlags().StringVar(&saveTxtPath, "save-txt", "", "Save ascii art as a .txt file\nFormat: <image-name>-ascii-art.txt\nFile will be saved in passed path\n(pass . for current directory)\n")
rootCmd.PersistentFlags().StringVar(&saveGifPath, "save-gif", "", "If input is a gif, save it as a .gif file\nFormat: <gif-name>-ascii-art.gif\nGif will be saved in passed path\n(pass . for current directory)\n")
rootCmd.PersistentFlags().IntSliceVar(&saveBgColor, "save-bg", nil, "Set background color for --save-img\nand --save-gif flags\nPass an RGBA value\ne.g. --save-bg 255,255,255,100\n(Defaults to 0,0,0,1)\n")
rootCmd.PersistentFlags().IntSliceVar(&saveBgColor, "save-bg", nil, "Set background color for --save-img\nand --save-gif flags\nPass an RGBA value\ne.g. --save-bg 255,255,255,100\n(Defaults to 0,0,0,100)\n")
rootCmd.PersistentFlags().StringVar(&fontFile, "font", "", "Set font for --save-img and --save-gif flags\nPass file path to font .ttf file\ne.g. --font ./RobotoMono-Regular.ttf\n(Defaults to Hack-Regular for ascii and\n DejaVuSans-Oblique for braille)\n")
rootCmd.PersistentFlags().IntSliceVar(&fontColor, "font-color", nil, "Set font color for terminal as well as\n--save-img and --save-gif flags\nPass an RGB value\ne.g. --font-color 0,0,0\n(Defaults to 255,255,255)\n")
rootCmd.PersistentFlags().BoolVar(&onlySave, "only-save", false, "Don't print ascii art on terminal\nif some saving flag is passed\n")

View File

@@ -115,13 +115,13 @@ func checkInputAndFlags(args []string) bool {
}
if saveBgColor[0] < 0 || saveBgColor[1] < 0 || saveBgColor[2] < 0 || saveBgColor[3] < 0 {
fmt.Printf("Error: RBG values must be between 0 and 255\n\n")
fmt.Printf("Error: RBG values must be between 0 and 255\n")
fmt.Printf("Error: Opacity value must be between 0 and 100\n\n")
return true
}
if saveBgColor[0] > 255 || saveBgColor[1] > 255 || saveBgColor[2] > 255 || saveBgColor[3] > 100{
fmt.Printf("Error: RBG values must be between 0 and 255\n\n")
if saveBgColor[0] > 255 || saveBgColor[1] > 255 || saveBgColor[2] > 255 || saveBgColor[3] > 100 {
fmt.Printf("Error: RBG values must be between 0 and 255\n")
fmt.Printf("Error: Opacity value must be between 0 and 100\n\n")
return true
}