Goalng exec.Command with exiftool creates extra file named {filename}_original when setting tags

huangapple go评论86阅读模式
英文:

Goalng exec.Command with exiftool creates extra file named {filename}_original when setting tags

问题

我正在尝试使用golang更新图像元数据。我找到的最简单的方法是使用os/exec运行exiftool,但由于某种原因,这还会创建一个包含原始标签的文件,文件名为原始文件名加上"_original"。

简化的代码如下:

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

这段代码确实按预期设置了标签,但会创建一个额外的文件,文件名为"image.png_original"。据我所知,这没有任何理由发生。我已经查看了os/exec和exiftool的文档,但没有找到任何相关信息。

虽然我可以删除额外的文件,但这样做很麻烦,我相信一定有更好的方法,只是我还没有找到。

感谢任何帮助 Goalng exec.Command with exiftool creates extra file named {filename}_original when setting tags

英文:

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 Goalng exec.Command with exiftool creates extra file named {filename}_original when setting tags

答案1

得分: 1

根据exiftool文档所说,你可以使用选项"-delete_original"。根据你的具体用例,你也可以考虑使用"-overwrite_original"选项。你可以阅读文档获取更多信息。

英文:

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

huangapple
  • 本文由 发表于 2022年11月19日 11:56:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/74497442.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定