You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
709 B
43 lines
709 B
package main
|
|
|
|
import (
|
|
"os"
|
|
"encoding/json"
|
|
"log"
|
|
)
|
|
|
|
type Conversion struct {
|
|
PixelWidth int
|
|
ColorDepth int
|
|
DitherType int
|
|
Width int
|
|
Height int
|
|
}
|
|
|
|
type Settings struct {
|
|
Source string
|
|
Target string
|
|
Include []string
|
|
Base Conversion
|
|
Exceptions map[string]Conversion
|
|
}
|
|
|
|
func LoadSettings(path string) Settings {
|
|
var settings Settings
|
|
|
|
config, err := os.ReadFile(path)
|
|
if err != nil {
|
|
log.Fatalf("invalid config path: %s", path)
|
|
}
|
|
|
|
err = json.Unmarshal(config, &settings)
|
|
if err != nil {
|
|
log.Fatalf("json format error:", err)
|
|
}
|
|
|
|
if len(settings.Include) == 0 {
|
|
log.Fatalf("You must have at least 1 extesion in Include in ", path)
|
|
}
|
|
|
|
return settings
|
|
}
|
|
|