mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
fix: compress screenshot image file
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user