Skip to content

Thumbnail offset gets corrupted when updating a tag #70

Description

@vinser

Hi,
This trivial code corrupts thumbnail

package main

import (
	"log"
	"os"

	exifkniferead "github.com/dsoprea/go-exif-knife/handler/read"
	exifknifewrite "github.com/dsoprea/go-exif-knife/handler/write"
)

func main() {
	inPath := os.Args[1]
	outPath := os.Args[2]

	readExifTag(inPath)
	writeExifTag(inPath, outPath)
	readExifTag(outPath)
}

func readExifTag(inPath string) {

	er := new(exifkniferead.ExifRead)

	err := er.Read(inPath, false, "", []string{"DateTimeOriginal"}, false, false, true)
	fatalIf(err)
}

func writeExifTag(inPath, outPath string) {
	ew := new(exifknifewrite.ExifWrite)

	err := ew.Write(inPath, []string{"IFD/Exif,DateTimeOriginal,2021:10:26 00:00:00"}, outPath)
	fatalIf(err)
}

func fatalIf(err error) {
	if err != nil {
		log.Fatal(err)
	}
}

Source image - jpeg_in
exiftool output before - exif_in.txt
Updated image - jpeg_out
exiftool output after - exif_out.txt - HERE you can see corruptions

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions