Compress the image to the specified size using a dichotomy
go get github.com/pzxy/compress
b, err := os.ReadFile("img.jpg")
if err != nil {
t.Fatal(err)
}
b, err = compress.CompressImage(b, 0, 100, 200, 10)
if err != nil {
t.Fatal(err)
}
_ = os.WriteFile("img2.jpg", b, 0644)