fix: compress screenshot image file

This commit is contained in:
lilong.129
2024-09-14 13:36:18 +08:00
parent 87f9c6808e
commit a2e5a35be2
2 changed files with 31 additions and 8 deletions
+8 -8
View File
@@ -6,7 +6,7 @@ import (
"image"
"image/gif"
"image/jpeg"
"image/png"
_ "image/png"
"os"
"path/filepath"
"strings"
@@ -216,14 +216,14 @@ func saveScreenShot(raw *bytes.Buffer, fileName string) (string, error) {
// compress image and save to file
switch format {
case "jpeg":
jpegOptions := &jpeg.Options{Quality: 90}
case "jpeg", "png":
jpegOptions := &jpeg.Options{Quality: 95}
err = jpeg.Encode(file, img, jpegOptions)
case "png":
encoder := png.Encoder{
CompressionLevel: png.BestCompression,
}
err = encoder.Encode(file, img)
// case "png":
// encoder := png.Encoder{
// CompressionLevel: png.BestCompression,
// }
// err = encoder.Encode(file, img)
case "gif":
gifOptions := &gif.Options{
NumColors: 256,