TheZoraiz / ascii-image-converter

A cross-platform command-line tool to convert images into ascii art and print them on the console. Now supports braille art!
Apache License 2.0
2.05k stars 121 forks source link

Unable to only save with color using go library #32

Open AuroraLi opened 1 year ago

AuroraLi commented 1 year ago

I am using the go library where a terminal isn't available. It works fine without color, but is throwing error when I set color flag to true

Error:

your terminal supports neither 24-bit nor 8-bit colors. Other coloring options aren't available

Code:

width, err := strconv.Atoi(os.Getenv("WIDTH"))
if err != nil {
  panic(err)
}
color := os.Getenv("COLOR")
if len(color) == 0 {
   color = "false" 
}
color_bool, err := strconv.ParseBool(os.Getenv("COLOR"))
if err != nil {
  panic(err)
}
fmt.Println("filename: " + file)
flags := aic_package.DefaultFlags()
flags.SaveImagePath = "."
flags.Colored = color_bool
flags.OnlySave = true
flags.Dimensions = []int{width * 2, width}
fmt.Println("the flags are "+ strconv.FormatBool(flags.OnlySave))
asciiArt, err := aic_package.Convert(file, flags)
if err != nil {
  fmt.Println(err)
}
if (len(asciiArt)>0){
  fmt.Printf("the converted file is %v\n", asciiArt)
}

How can I save a colored ASCII file?

TheZoraiz commented 1 year ago

Looks like solution to this would be applicable for issue #31 as well. I'll release an update for this as soon as I get time.