cleaning main + quiet mode
This commit is contained in:
parent
13923ff12f
commit
c1e5e08a2b
18
config.go
18
config.go
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -18,6 +19,7 @@ type Config struct {
|
|||||||
OutputHeight int `json:output_height`
|
OutputHeight int `json:output_height`
|
||||||
Grayscale bool
|
Grayscale bool
|
||||||
Amount int
|
Amount int
|
||||||
|
Quiet bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// loads configuration values from json file
|
// loads configuration values from json file
|
||||||
@ -43,5 +45,21 @@ func (c *Config) SetOutputDimensions() {
|
|||||||
c.OutputHeight = height
|
c.OutputHeight = height
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func initConfigRegister() {
|
||||||
|
// command line arguments
|
||||||
|
flag.StringVar(&ConfigRegister.Method, "blending", "darken", "Blending methods : darken, lighten, fuckyfun")
|
||||||
|
flag.StringVar(&ConfigRegister.OutputDir, "output", "./", "Output directory")
|
||||||
|
flag.StringVar(&ConfigRegister.InputDir, "input", "/home/gator/Photos", "Input directory. Where to look the images from")
|
||||||
|
flag.StringVar(&ConfigRegister.BaseImage, "base-img", "", "Path to the base image to work with. Random image if not set")
|
||||||
|
flag.StringVar(&ConfigRegister.Dimensions, "dimensions", "1280x1024", "Out image dimensions. <width>x<height>")
|
||||||
|
flag.BoolVar(&ConfigRegister.Grayscale, "grayscale", false, "Output image in shade of gray (around 50)")
|
||||||
|
flag.IntVar(&ConfigRegister.Amount, "amount", 2, "Number of images to blend together")
|
||||||
|
flag.BoolVar(&ConfigRegister.Quiet, "quiet", false, "No progress messages")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
// set output's width and height
|
||||||
|
ConfigRegister.SetOutputDimensions()
|
||||||
|
}
|
||||||
|
|
||||||
// global register to acccess configuration values
|
// global register to acccess configuration values
|
||||||
var ConfigRegister Config
|
var ConfigRegister Config
|
||||||
|
22
main.go
22
main.go
@ -1,28 +1,24 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
_ "image/jpeg"
|
_ "image/jpeg"
|
||||||
_ "image/png"
|
_ "image/png"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// command line arguments
|
// store command line arguments into the register
|
||||||
flag.StringVar(&ConfigRegister.Method, "blending", "darken", "Blending methods : darken, lighten, fuckyfun")
|
initConfigRegister()
|
||||||
flag.StringVar(&ConfigRegister.OutputDir, "output", "./", "Output directory")
|
|
||||||
flag.StringVar(&ConfigRegister.InputDir, "input", "/home/gator/Photos", "Input directory. Where to look the images from")
|
|
||||||
flag.StringVar(&ConfigRegister.BaseImage, "base-img", "", "Path to the base image to work with. Random image if not set")
|
|
||||||
flag.StringVar(&ConfigRegister.Dimensions, "dimensions", "1280x1024", "Out image dimensions. <width>x<height>")
|
|
||||||
flag.BoolVar(&ConfigRegister.Grayscale, "grayscale", false, "Output image in shade of gray (around 50)")
|
|
||||||
flag.IntVar(&ConfigRegister.Amount, "amount", 2, "Number of images to blend together")
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
// set output's width and height
|
if ConfigRegister.Quiet {
|
||||||
ConfigRegister.SetOutputDimensions()
|
log.SetOutput(ioutil.Discard)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// pool of workers unionizing, ready to blend a new picture using the power of friendship
|
// pool of workers unionizing, ready to blend a new picture using the power of friendship
|
||||||
var pool blendWorkerPool
|
var pool blendWorkerPool
|
||||||
|
|
||||||
// main blending routine
|
// launch main blending routine
|
||||||
pool.BlendImagesMain()
|
pool.BlendImagesMain()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user