1

I'm attempting to update image metadata using golang. The simplest way I've found to do this is simply running exiftool with os/exec, but for some reason this also creates a file that contains the original tags, called whatever the original file is called, plus "_original".

Simplified code is as follows:

func main() {
    cmd := exec.Command("exiftool", "-ImageDescription=\"this should work???\"", "image.png")
    err := cmd.Run()
    if err != nil {
        log.Fatal(err)
    }
}

It does set the tags as expected, but creates an extra file called "image.png_original". As far as I can tell this has no reason to happen. I've checked documentation for os/exec as well as exiftool and haven't found anything.

While I could just delete the extra file, that's messy and I'm sure there's a better way that I just haven't been able to figure out.

Any help is appreciated :)

1 Answers1

1

As the exiftool documentation says, you can use the option "-delete_original" . You can consider "-overwrite_original" option as well, depending on your exact use case. You can read the docs for more information

ABDULLOKH MUKHAMMADJONOV
  • 4,249
  • 3
  • 22
  • 40
  • 1
    Direct link to the [`-overwrite_original` option](https://exiftool.org/exiftool_pod.html#overwrite_original). This is most likely the option you want to use. There is also the [`-overwrite_original_in_place` option](https://exiftool.org/exiftool_pod.html#overwrite_original_in_place), but that is slower and you usually only want to use that in cases where there is other filesystem data attached to the file, such as `XAttr`/`MDItem` on Mac or ADS on Windows. – StarGeek Nov 19 '22 at 14:33