1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 11:07:40 +08:00

calc image size

This commit is contained in:
Mrs4s 2023-06-10 16:22:26 +08:00
parent 7c68459666
commit 6352f22009
No known key found for this signature in database
GPG Key ID: 3186E98FA19CE3A7

View File

@ -158,6 +158,10 @@ func (c *QQClient) uploadPrivateImage(target int64, img io.ReadSeeker, count int
count++ count++
fh, length := utils.ComputeMd5AndLength(img) fh, length := utils.ComputeMd5AndLength(img)
_, _ = img.Seek(0, io.SeekStart) _, _ = img.Seek(0, io.SeekStart)
i, _, _ := imgsz.DecodeSize(img)
_, _ = img.Seek(0, io.SeekStart)
width := int32(i.Width)
height := int32(i.Height)
e, err := c.QueryFriendImage(target, fh, int32(length)) e, err := c.QueryFriendImage(target, fh, int32(length))
if errors.Is(err, ErrNotExists) { if errors.Is(err, ErrNotExists) {
groupSource := message.Source{ groupSource := message.Source{
@ -176,6 +180,8 @@ func (c *QQClient) uploadPrivateImage(target int64, img io.ReadSeeker, count int
if err != nil { if err != nil {
return nil, err return nil, err
} }
e.Height = height
e.Width = width
return e, nil return e, nil
} }