Update timestamp

This commit is contained in:
Milan Nikolic
2025-06-15 08:47:13 +02:00
parent d84884f26b
commit 6826193e2c
4 changed files with 8 additions and 7 deletions

View File

@@ -144,7 +144,7 @@ func (c *Camera) Read() (img image.Image, err error) {
} }
if c.opts.Timestamp { if c.opts.Timestamp {
img, err = im.Timestamp(img, c.opts.TimeFormat) img = im.Timestamp(img, c.opts.TimeFormat)
} }
return return

View File

@@ -74,7 +74,7 @@ func (c *Camera) Read() (img image.Image, err error) {
} }
if c.opts.Timestamp { if c.opts.Timestamp {
img, err = im.Timestamp(img, c.opts.TimeFormat) img = im.Timestamp(img, c.opts.TimeFormat)
} }
return return

View File

@@ -186,7 +186,7 @@ func (c *Camera) Read() (img image.Image, err error) {
} }
if c.opts.Timestamp { if c.opts.Timestamp {
img, err = im.Timestamp(img, c.opts.TimeFormat) img = im.Timestamp(img, c.opts.TimeFormat)
} }
return return

View File

@@ -1,7 +1,6 @@
package image package image
import ( import (
"fmt"
"image" "image"
"image/color" "image/color"
"image/draw" "image/draw"
@@ -35,13 +34,15 @@ func Flip(img image.Image, dir string) image.Image {
return img return img
} }
func Timestamp(img image.Image, format string) (image.Image, error) { func Timestamp(img image.Image, format string) image.Image {
dimg, ok := img.(draw.Image) dimg, ok := img.(draw.Image)
if !ok { if !ok {
return img, fmt.Errorf("camera: %T is not a drawable image type", img) b := img.Bounds()
dimg = image.NewRGBA(image.Rect(0, 0, b.Dx(), b.Dy()))
draw.Draw(dimg, b, img, b.Min, draw.Src)
} }
pixfont.DrawString(dimg, 10, 10, time.Now().Format(format), color.White) pixfont.DrawString(dimg, 10, 10, time.Now().Format(format), color.White)
return dimg, nil return dimg
} }