有没有办法在go中检查heic或heif文件格式?对于图像,我以前使用_, format, err := image.DecodeConfig(bytes.NewReader(file))
检查文件是jpeg还是png。当检查heic文件时,它是完全空的。
最佳答案
如果您在Linux或Mac中,则可以使用mdls
命令获取文件类型。
例子:
$ mdls camel.heic
kMDItemBitsPerSample = 32
kMDItemColorSpace = "RGB"
kMDItemContentCreationDate = 2018-10-03 11:36:30 +0000
kMDItemContentCreationDate_Ranking = 2018-10-03 00:00:00 +0000
kMDItemContentModificationDate = 2018-10-03 11:36:31 +0000
kMDItemContentType = "public.heic"
...
您可以在
golang
中运行以下命令并获取kMDItemContentType
的数据out, err := exec.Command("mdls", "camel.heic").Output()
# parse data from `out`
关于image - 在Golang中检查HEIC文件格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52625273/