This is a creation in Article, where the information may have evolved or changed.
Imagecode.gopackage mainimport ("bytes" "FMT" "Os/exec" "Path/filepath" "Strings" "Image" "Image/jpeg" "Io/ioutil" "Os ") func main () {//read a picture, FF for []byte type FF, _: = Ioutil. ReadFile ("image1.jpg")//write ff to file _ = Ioutil. WriteFile ("./output.jpg.txt", FF, 0666)//Create a new cache bbb: = bytes. Newbuffer (FF)//Decodes a byte m, _, _: = image. Decode (BBB)//Create a new file F, _: = OS. Create ("Output.jpg") fmt. Println ("F Name:", F.name ()) defer f.close () jpeg. Encode (f, M, nil)//Gets the current execution path str: = Getcurrentpath () fmt. Println ("End:", str) FMT. Println ("End:", Str+f.name ())}func Getcurrentpath () string {file, _: = Exec. Lookpath (OS. Args[0]) fmt. Println ("File:", file) path, _: = FilePath. Abs (file) fmt. Println ("Path:", path) splitstring: = Strings. Split (path, "\ \") Size: = Len (splitstring) splitstring = strings. Split (path, splitstring[size-1]) ret: = Strings. Replace (splitstring[0], "\ \", "/", size-1) return ret}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.