Skip to content

Commit 5e2c902

Browse files
committed
原来一直白压缩了这么久
1 parent 48f3ddd commit 5e2c902

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

cmd/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
const (
10-
Version string = "0.7.4"
10+
Version string = "0.7.5"
1111
)
1212

1313
var VersionCmd = &cobra.Command{

common/image.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ func CompressImage(input []byte, maxSizeMB, maxEdgeLength uint) ([]byte, error)
114114
quality := 100
115115
var buf bytes.Buffer
116116
if len(input) < int(maxSizeMB*1024*1024) {
117-
return input, nil
117+
err := jpeg.Encode(&buf, img, &jpeg.Options{Quality: quality})
118+
if err != nil {
119+
return nil, err
120+
}
121+
return buf.Bytes(), nil
118122
}
119123
for {
120124
buf.Reset()

0 commit comments

Comments
 (0)