Skip to content

Instantly share code, notes, and snippets.

@oldpatricka
Created November 6, 2018 20:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oldpatricka/f4137738a56c85e9c70f1ac88e3e3e30 to your computer and use it in GitHub Desktop.
Save oldpatricka/f4137738a56c85e9c70f1ac88e3e3e30 to your computer and use it in GitHub Desktop.
Simple program to dump TIFF metadata
package main
// To run, first install github.com/google/tiff with:
// go get github.com/google/tiff
// Then run like `go run tiff-dump.go example.tif`
import (
"fmt"
"github.com/google/tiff"
"os"
)
func main() {
tiffFile := os.Args[1]
r, err := os.Open(tiffFile)
if err != nil {
panic(err)
}
tiff.SetTiffFieldPrintFullFieldValue(true)
t, err := tiff.Parse(r, nil, nil)
if err != nil {
panic(err)
}
fmt.Printf("Version: %d\n", t.Version())
fmt.Printf("Byte Order: %s\n\n", EndianString(t.Order()))
for i, ifd := range t.IFDs() {
fmt.Printf("IFD %d:\n", i)
for _, f := range ifd.Fields() {
fmt.Printf("%s\n", f)
}
}
}
func EndianString(magicEndian string) string {
if magicEndian == tiff.MagicBigEndian {
return "big endian"
} else {
return "little endian"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment