Is there a way to check for HEIC or HEIF file format in Go? For images, I was previously using _, format, err := image.DecodeConfig(bytes.NewReader(file))
to check if a file was a jpeg or png. When checking against a HEIC file, it's completely empty.
if you are in Linux or Mac then you can use the mdls
command to get the file type.
example :
$ 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"
...
you can run the following command within golang
and get the data for kMDItemContentType
out, err := exec.Command("mdls", "camel.heic").Output()
# parse data from `out`