diff --git a/cmd/tagger/flags.go b/cmd/tagger/flags.go index e55d85f..27ccb17 100644 --- a/cmd/tagger/flags.go +++ b/cmd/tagger/flags.go @@ -30,6 +30,7 @@ var ( // Flags var ( displayHelp bool = false + copyright string = "" exiftoolBinary string = "exiftool" filenamePattern string = `FILM_${cameraID:02d}${filmID:03d}${frameNo:05d}.dng` fileSource string = "" @@ -52,6 +53,7 @@ func parseFlags() { } flag.BoolVar(&displayHelp, "help", displayHelp, "display help message") + flag.StringVar(©right, "copyright", copyright, "copyright notice for images") flag.StringVar(&exiftoolBinary, "exiftool-binary", exiftoolBinary, "path to exiftool binary") flag.StringVar(&filenamePattern, "filename-pattern", filenamePattern, "filename pattern for generate exiftool command. Available variables: frameNo, cameraID, filmID. More details are available in README.") flag.StringVar(&fileSource, "file-source", fileSource, "adds file source EXIF tag. Available options: 'Film Scanner', 'Reflection Print Scanner', 'Digital Camera'") diff --git a/cmd/tagger/main.go b/cmd/tagger/main.go index 9c0e3d2..1b996ae 100644 --- a/cmd/tagger/main.go +++ b/cmd/tagger/main.go @@ -68,6 +68,10 @@ func main() { et.FileSource(fileSource) } + if copyright != "" { + et.Copyright(copyright) + } + if geotag != "" { et.GeoTime(*f.Timestamp) et.GeoTag(geotag) diff --git a/exiftool/exiftool.go b/exiftool/exiftool.go index a193a12..8f6ca5e 100644 --- a/exiftool/exiftool.go +++ b/exiftool/exiftool.go @@ -92,6 +92,14 @@ func NewFromFrame(binary, filename string, f *types.Frame) *ExifTool { return et } +// Copyright sets EXIF copyright values +func (e *ExifTool) Copyright(cr string) *ExifTool { + e.add("IFD0:Artist", cr) + e.add("IFD0:Copyright", cr) + + return e +} + // Aperture sets Aperture parameters to exiftool command func (e *ExifTool) Aperture(v float64) *ExifTool { vs := strconv.FormatFloat(v, 'f', -1, 64) diff --git a/exiftool/exiftool_test.go b/exiftool/exiftool_test.go index 07061d3..a066e66 100644 --- a/exiftool/exiftool_test.go +++ b/exiftool/exiftool_test.go @@ -135,6 +135,14 @@ func TestExiftoolOptions(t *testing.T) { }, expCommand: `"-FileSource=Film Scanner" "test-file-with-file-source"`, }, + { + name: "copyright specified", + fname: "test-file-with-copyright", + f: func(e *ExifTool) { + e.Copyright("Test Copyright © 2020") + }, + expCommand: `"-IFD0:Artist=Test Copyright © 2020" "-IFD0:Copyright=Test Copyright © 2020" "test-file-with-copyright"`, + }, } for _, tc := range tcs {