示例#1
0
func TestMain(t *testing.T) {
	file_name := "eimyymF.png"
	file, err := os.Open("./" + file_name)
	ai, err := asciiimg.NewAsciiImg(file)
	if err == nil {
		ascii_txt, _ := os.Create(fmt.Sprintf("%s_ascii.txt", file_name))
		ascii_txt.Write([]byte(ai.Do(4, 8)))
		ascii_txt.Close()
	}
	fmt.Println("Test Complete.", err)
}
示例#2
0
func main() {
	file, err := os.Open(*srcImg)
	if err != nil {
		panic(fmt.Sprintln("File path error", err, *srcImg))
	}
	ai, _ := asciiimg.NewAsciiImg(file)

	if len(*destAscii) == 0 {
		*destAscii = fmt.Sprintf("%s_ascii.txt", file.Name())
	}

	ascii_txt, _ := os.Create(*destAscii)
	ascii_txt.Write([]byte(ai.DoByCol(*cols)))
	defer ascii_txt.Close()

	fmt.Printf("File save in %s", ascii_txt.Name())
}