1
0

resize picture based on specified dimensions

This commit is contained in:
2022-05-01 15:33:55 +02:00
parent b0e7cbbd2f
commit 1138d11923
3 changed files with 59 additions and 7 deletions

View File

@ -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