mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
feat: use the decoder which only parses size info (#238)
* fix: add GroupImage Width & Height for webp * fix: 简化写法 * feat: use imgsz package and drop image
This commit is contained in:
parent
9a45e430f1
commit
a5670ccc43
@ -3,13 +3,13 @@ package client
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"image"
|
||||
"io"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/fumiama/imgsz"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/Mrs4s/MiraiGo/binary"
|
||||
@ -82,7 +82,7 @@ func (c *QQClient) UploadGroupImage(groupCode int64, img io.ReadSeeker) (*messag
|
||||
return nil, errors.Wrap(err, "upload failed")
|
||||
ok:
|
||||
_, _ = img.Seek(0, io.SeekStart)
|
||||
i, _, _ := image.DecodeConfig(img)
|
||||
i, _, _ := imgsz.DecodeSize(img)
|
||||
var imageType int32 = 1000
|
||||
_, _ = img.Seek(0, io.SeekStart)
|
||||
tmp := make([]byte, 4)
|
||||
@ -135,7 +135,7 @@ func (c *QQClient) UploadGroupImageByFile(groupCode int64, path string) (*messag
|
||||
return nil, errors.Wrap(err, "upload failed")
|
||||
ok:
|
||||
_, _ = img.Seek(0, io.SeekStart)
|
||||
i, _, _ := image.DecodeConfig(img)
|
||||
i, _, _ := imgsz.DecodeSize(img)
|
||||
var imageType int32 = 1000
|
||||
_, _ = img.Seek(0, io.SeekStart)
|
||||
tmp := make([]byte, 4)
|
||||
|
1
go.mod
1
go.mod
@ -4,6 +4,7 @@ go 1.17
|
||||
|
||||
require (
|
||||
github.com/RomiChan/protobuf v0.0.0-20211223055824-048df49a8956
|
||||
github.com/fumiama/imgsz v0.0.2
|
||||
github.com/klauspost/compress v1.13.6
|
||||
github.com/pierrec/lz4/v4 v4.1.11
|
||||
github.com/pkg/errors v0.9.1
|
||||
|
2
go.sum
2
go.sum
@ -3,6 +3,8 @@ github.com/RomiChan/protobuf v0.0.0-20211223055824-048df49a8956/go.mod h1:CKKOWC
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/fumiama/imgsz v0.0.2 h1:fAkC0FnIscdKOXwAxlyw3EUba5NzxZdSxGaq3Uyfxak=
|
||||
github.com/fumiama/imgsz v0.0.2/go.mod h1:dR71mI3I2O5u6+PCpd47M9TZptzP+39tRBcbdIkoqM4=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
|
||||
|
Loading…
x
Reference in New Issue
Block a user