resize picture based on specified dimensions
This commit is contained in:
22
config.go
22
config.go
@ -4,13 +4,18 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Method string `json:method`
|
||||
OutputDir string `json:outputdir`
|
||||
InputDir string `json:inputdir`
|
||||
BaseImage string `json:baseimage`
|
||||
Method string `json:method`
|
||||
OutputDir string `json:outputdir`
|
||||
InputDir string `json:inputdir`
|
||||
BaseImage string `json:baseimage`
|
||||
Dimensions string `json:dimensions`
|
||||
OutputWidth int `json:output_width`
|
||||
OutputHeight int `json:output_height`
|
||||
}
|
||||
|
||||
// loads configuration values from json file
|
||||
@ -27,5 +32,14 @@ func (c *Config) LoadConfigFromFile(filePath string) {
|
||||
fmt.Println(configuration.OutputDir)
|
||||
}
|
||||
|
||||
// Set output file dimensions using string symbol (<width>x<height>)
|
||||
func (c *Config) SetOutputDimensions() {
|
||||
split := strings.Split(c.Dimensions, "x")
|
||||
width, _ := strconv.Atoi(split[0])
|
||||
height, _ := strconv.Atoi(split[1])
|
||||
c.OutputWidth = width
|
||||
c.OutputHeight = height
|
||||
}
|
||||
|
||||
// global register to acccess configuration values
|
||||
var ConfigRegister Config
|
||||
|
||||
Reference in New Issue
Block a user