-
Notifications
You must be signed in to change notification settings - Fork 0
/
exif.go
34 lines (26 loc) · 828 Bytes
/
exif.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package image
import (
"fmt"
"image"
"io"
"time"
"github.com/aaronland/go-image/exif"
)
// AppendTime appends the RFC3339-encoded value or 't' to the JPEG encoding of 'im'
// in its `DateTime`, `DateTimeDigitized` and `DateTimeOriginal` EXIF headers. The
// final JPEG encoding of 'im' is written to 'wr'.
func AppendTime(im image.Image, wr io.Writer, t time.Time) error {
// https://github.com/rwcarlsen/goexif/blob/go1/exif/exif.go#L385
jpeg_dt := t.Format("2006:01:02 15:04:05") // time.RFC3339)
exif_props := map[string]interface{}{
"DateTime": jpeg_dt,
"DateTimeDigitized": jpeg_dt,
"DateTimeOriginal": jpeg_dt,
"Software": "fingerprint",
}
err := exif.UpdateExif(im, wr, exif_props)
if err != nil {
return fmt.Errorf("Failed to update EXIF data, %w", err)
}
return nil
}