rwcarlsen / goexif

Decode embedded EXIF meta data from image files.
BSD 2-Clause "Simplified" License
627 stars 134 forks source link

PR #60 broke extracting makernotes #72

Open mostlygeek opened 5 years ago

mostlygeek commented 5 years ago

I use goexif to extract and parse the maker notes for apple device created jpegs. I had PR #62 opened last year. That PR is broken now so I closed it.

It seems extracting exif.MakerNote is broken in general

I wrote this little testing program

package main

import (
    "flag"
    "fmt"
    "os"

    "github.com/rwcarlsen/goexif/exif"
)

func main() {
    flag.Parse()
    filename := flag.Arg(0)
    f, err := os.Open(filename)
    if err != nil {
        fmt.Println("File error: ", err.Error())
        return
    }

    x, err := exif.Decode(f)
    if err != nil {
        fmt.Println("Decode error: ", err.Error())
        return
    }

    m, err := x.Get(exif.MakerNote)
    if err != nil {
        fmt.Println("Error: ", err.Error())
    } else {
        fmt.Printf("OK.  Extracted %d bytes\n\n%x\n", len(m.Val), m.Val)
    }
}

With goexif@9b9b2b

$ go run ./test-extract.go testdata/apple_contentid.jpg
OK.  Extracted 1000 bytes

4170706c6 ... (the rest of the data) 

With goexif@76e334

$ go run ./test-extract.go testdata/apple_contentid.jpg
OK.  Extracted 0 bytes

Here is the testing image ... the makenotes where copied into it from another file with exiftool. apple_contentid

rwcarlsen commented 5 years ago

Hm... Strange that the 3 regression tests that have makernotes still pass. I'll poke around a bit over the coming days. I'm not sure how much time I can give it. If the hunt doesn't pan out, I'll consider reverting.