Hey there i'd like to upload some picture on twitter but due to a size limitation i can't so i'd like to compress them a bit. i found this library : https://github.com/h2non/bimg but didn't found any example on how to convert a png to jpg, or just to compress an existing jpg file can someone help me please, this could be using the same library or another one
here is what i got but didn't managed to run it on windows to test it
package main
import (
"fmt"
"os"
"github.com/h2non/bimg"
)
func main() {
//convert png file to jpg with a quality of 80
buffer, err := bimg.Read("2371.png")
if err != nil {
fmt.Fprintln(os.Stderr, err)
}
newImage, err := bimg.NewImage(buffer).Convert(bimg.JPEG)
if err != nil {
fmt.Fprintln(os.Stderr, err)
}
err = bimg.Write("image.jpg", newImage)
if err != nil {
fmt.Fprintln(os.Stderr, err)
}
}