Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33438c5169 | ||
|
|
605698cff7 |
@@ -8,6 +8,7 @@ import (
|
|||||||
"image/png"
|
"image/png"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ func CaptureImage() bool {
|
|||||||
|
|
||||||
if resp.Body != nil {
|
if resp.Body != nil {
|
||||||
timestamp := time.Now()
|
timestamp := time.Now()
|
||||||
filename := timestamp.Format("/axis-2006-01-02_15-04-05.jpg")
|
filename := timestamp.Format("/axis-2006-01-02_15-04-05.png")
|
||||||
|
|
||||||
img, _, err := image.Decode(resp.Body)
|
img, _, err := image.Decode(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -53,6 +54,13 @@ func CaptureImage() bool {
|
|||||||
log.Fatal().Err(err).Msgf("")
|
log.Fatal().Err(err).Msgf("")
|
||||||
} else {
|
} else {
|
||||||
log.Info().Msg("New image created: " + config.StoragePath + filename)
|
log.Info().Msg("New image created: " + config.StoragePath + filename)
|
||||||
|
|
||||||
|
cmd := exec.Command("cp", config.StoragePath+filename, config.StoragePath+"/latest.png")
|
||||||
|
|
||||||
|
err := cmd.Run()
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Msgf("Error copying to latest.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user