configurable input directory

This commit is contained in:
Ali Gator 2022-05-01 09:48:37 +02:00
parent 11983d971b
commit 6c29d534d5
3 changed files with 3 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import (
type Config struct { type Config struct {
Method string `json:method` Method string `json:method`
OutputDir string `json:outputdir` OutputDir string `json:outputdir`
InputDir string `json:inputdir`
BaseImage string `json:baseimage` BaseImage string `json:baseimage`
} }

2
fs.go
View File

@ -53,7 +53,7 @@ func getImagesList(path string) []string {
// Randomly choose x number of image from a given folder // Randomly choose x number of image from a given folder
func getRandomImage() string { func getRandomImage() string {
rand.Seed(time.Now().UnixNano()) rand.Seed(time.Now().UnixNano())
dir := getImagesList("/home/gator/Photos/") dir := getImagesList(ConfigRegister.InputDir)
index := rand.Intn(len(dir)) index := rand.Intn(len(dir))
return dir[index] return dir[index]
} }

View File

@ -11,6 +11,7 @@ func main() {
// command line arguments // command line arguments
flag.StringVar(&ConfigRegister.Method, "blending", "darken", "Blending methods : darken, lighten, fuckyfun") flag.StringVar(&ConfigRegister.Method, "blending", "darken", "Blending methods : darken, lighten, fuckyfun")
flag.StringVar(&ConfigRegister.OutputDir, "output", "./", "Output directory") 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.BaseImage, "base-img", "", "Path to the base image to work with. Random image if not set")
flag.Parse() flag.Parse()