Temp files are now stored in system temp dir
This commit is contained in:
@@ -24,6 +24,14 @@ func CreateBanner(portalhex string, savename string, vopt int) {
|
||||
var err error
|
||||
var GlyphHex [12]int64
|
||||
var glyphImg [12]string
|
||||
|
||||
// Setup temp dir
|
||||
tempdir, err := ioutil.TempDir("", ".gotemp")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer os.RemoveAll(tempdir)
|
||||
|
||||
// verify len of portalhex
|
||||
if len(portalhex) == 12 {
|
||||
// get hex value from each digit in given string to an array of int64
|
||||
@@ -35,7 +43,7 @@ func CreateBanner(portalhex string, savename string, vopt int) {
|
||||
}
|
||||
// assign image location of its glyph hex value to an array of strings
|
||||
for j := 0; j < len(glyphImg); j++ {
|
||||
glyphImg[j] = fmt.Sprintf("tmp.nmslib/glyphs/GLYPH-%X.png", GlyphHex[j])
|
||||
glyphImg[j] = fmt.Sprintf("glyphs/GLYPH-%X.png", GlyphHex[j])
|
||||
}
|
||||
// pull images need from glyph.go and saved them to ./glyphs/
|
||||
for k := 0; k < len(glyphImg); k++ {
|
||||
@@ -43,24 +51,25 @@ func CreateBanner(portalhex string, savename string, vopt int) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_, err2 := os.Stat("tmp.nmslib/glyphs")
|
||||
_, err2 := os.Stat(tempdir + "/glyphs/")
|
||||
if os.IsNotExist(err2) {
|
||||
errDir := os.MkdirAll("tmp.nmslib/glyphs", 0755)
|
||||
errDir := os.MkdirAll(tempdir+"/glyphs", 0755)
|
||||
if errDir != nil {
|
||||
panic(errDir)
|
||||
}
|
||||
}
|
||||
err = ioutil.WriteFile(glyphImg[k], []byte(data), 0644)
|
||||
|
||||
err = ioutil.WriteFile(tempdir+"/"+glyphImg[k], []byte(data), 0644)
|
||||
}
|
||||
}
|
||||
// load images for processing using github.com/ozankasikci/go-image-merge
|
||||
grids := []*gim.Grid{
|
||||
{ImageFilePath: glyphImg[0]}, {ImageFilePath: glyphImg[1]},
|
||||
{ImageFilePath: glyphImg[2]}, {ImageFilePath: glyphImg[3]},
|
||||
{ImageFilePath: glyphImg[4]}, {ImageFilePath: glyphImg[5]},
|
||||
{ImageFilePath: glyphImg[6]}, {ImageFilePath: glyphImg[7]},
|
||||
{ImageFilePath: glyphImg[8]}, {ImageFilePath: glyphImg[9]},
|
||||
{ImageFilePath: glyphImg[10]}, {ImageFilePath: glyphImg[11]},
|
||||
{ImageFilePath: tempdir + "/" + glyphImg[0]}, {ImageFilePath: tempdir + "/" + glyphImg[1]},
|
||||
{ImageFilePath: tempdir + "/" + glyphImg[2]}, {ImageFilePath: tempdir + "/" + glyphImg[3]},
|
||||
{ImageFilePath: tempdir + "/" + glyphImg[4]}, {ImageFilePath: tempdir + "/" + glyphImg[5]},
|
||||
{ImageFilePath: tempdir + "/" + glyphImg[6]}, {ImageFilePath: tempdir + "/" + glyphImg[7]},
|
||||
{ImageFilePath: tempdir + "/" + glyphImg[8]}, {ImageFilePath: tempdir + "/" + glyphImg[9]},
|
||||
{ImageFilePath: tempdir + "/" + glyphImg[10]}, {ImageFilePath: tempdir + "/" + glyphImg[11]},
|
||||
}
|
||||
if vopt == 1 {
|
||||
// Merge images horizontally
|
||||
@@ -83,9 +92,4 @@ func CreateBanner(portalhex string, savename string, vopt int) {
|
||||
file, err := os.Create(savename)
|
||||
err = png.Encode(file, rgba)
|
||||
}
|
||||
// remove glyphs folder to keep it clean
|
||||
errDir := os.RemoveAll("tmp.nmslib/glyphs")
|
||||
if errDir != nil {
|
||||
panic(errDir)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user