I have a service that compares two base64 encoded image strings
My initial attempt revealed that there is differences in metadata while the actual image (JPG) in this case is identical (size,resolution,dimensions,etc).
Is there a way to strip away much of the dynamic metadata so that I can just compare the visual aspect of the image?
Currently, I am using the following...
package converter
import (
"bufio"
"encoding/base64"
"log"
"os"
)
func Base64(path string) (string, error) {
imgFile, err := os.Open(path)
if err != nil {
log.Fatalln(err)
}
defer imgFile.Close()
// create a new buffer base on file size
fInfo, _ := imgFile.Stat()
var size int64 = fInfo.Size()
buf := make([]byte, size)
// read file content into buffer
fReader := bufio.NewReader(imgFile)
fReader.Read(buf)
// convert the buffer bytes to base64 string - use buf.Bytes() for new image
imgBase64Str := base64.StdEncoding.EncodeToString(buf)
return imgBase64Str,nil
}