Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Commit

Permalink
Add ability to set copyright fields
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Shishkin <[email protected]>
  • Loading branch information
teran committed Jan 5, 2020
1 parent 5cc07b5 commit 486e9d1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/tagger/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand All @@ -52,6 +53,7 @@ func parseFlags() {
}

flag.BoolVar(&displayHelp, "help", displayHelp, "display help message")
flag.StringVar(&copyright, "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'")
Expand Down
4 changes: 4 additions & 0 deletions cmd/tagger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ func main() {
et.FileSource(fileSource)
}

if copyright != "" {
et.Copyright(copyright)
}

if geotag != "" {
et.GeoTime(*f.Timestamp)
et.GeoTag(geotag)
Expand Down
8 changes: 8 additions & 0 deletions exiftool/exiftool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions exiftool/exiftool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 486e9d1

Please sign in to comment.