export the color palette in a goroutine
This commit is contained in:
parent
e00a6e8f6e
commit
d550414b7c
2 changed files with 9 additions and 8 deletions
|
@ -13,14 +13,15 @@ import (
|
|||
)
|
||||
|
||||
// write the base16 color palette to a file
|
||||
func exportPalette(image string) error {
|
||||
func exportPalette(image string) {
|
||||
if !config.IsPaletteSet() {
|
||||
return nil
|
||||
return
|
||||
}
|
||||
var palette string
|
||||
colors, error := getColorPalette(image, 16)
|
||||
if error != nil {
|
||||
return error
|
||||
loggo.Error("encountered an error getting the color palette for image", "image: "+image, error.Error())
|
||||
return
|
||||
}
|
||||
for index, color := range colors {
|
||||
if index > 0 {
|
||||
|
@ -33,7 +34,10 @@ func exportPalette(image string) error {
|
|||
tmp = "SLIDESHOW_COLOR" + tmp
|
||||
palette += tmp + "=\"" + rgbToHex(color) + "\""
|
||||
}
|
||||
return os.WriteFile(config.Palette, []byte(palette), 0775)
|
||||
error = os.WriteFile(config.Palette, []byte(palette), 0775)
|
||||
if error != nil {
|
||||
loggo.Error("encountered an error exporting the color palette for image", "image: "+image, error.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// get the base16 color palette from an image
|
||||
|
|
|
@ -45,10 +45,7 @@ func Start() {
|
|||
loggo.Debug("sleeping for " + strconv.FormatInt(sleepTime.Milliseconds(), 10) + "ms")
|
||||
time.Sleep(sleepTime)
|
||||
}
|
||||
error := exportPalette(image)
|
||||
if error != nil {
|
||||
loggo.Error("encountered an error exporting the color palette for image", "image: "+image, error.Error())
|
||||
}
|
||||
go exportPalette(image)
|
||||
if scaleImages {
|
||||
error := setBackgroundPiped(data)
|
||||
if error != nil {
|
||||
|
|
Loading…
Reference in a new issue