mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-05 03:23:50 +08:00
fix height width
This commit is contained in:
parent
0753140ccd
commit
f65eda3c20
@ -7,6 +7,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"image"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
@ -645,11 +646,12 @@ func (c *QQClient) UploadGroupImage(groupCode int64, img []byte) (*message.Group
|
|||||||
}
|
}
|
||||||
return nil, errors.New("upload failed")
|
return nil, errors.New("upload failed")
|
||||||
ok:
|
ok:
|
||||||
|
i, _, _ := image.DecodeConfig(bytes.NewReader(img))
|
||||||
var imageType int32 = 1000
|
var imageType int32 = 1000
|
||||||
if bytes.HasPrefix(img, []byte{0x47, 0x49, 0x46, 0x38}) {
|
if bytes.HasPrefix(img, []byte{0x47, 0x49, 0x46, 0x38}) {
|
||||||
imageType = 2000
|
imageType = 2000
|
||||||
}
|
}
|
||||||
return message.NewGroupImage(binary.CalculateImageResourceId(h[:]), h[:], rsp.FileId, int32(len(img)), rsp.Width, rsp.Height, imageType), nil
|
return message.NewGroupImage(binary.CalculateImageResourceId(h[:]), h[:], rsp.FileId, int32(len(img)), int32(i.Width), int32(i.Height), imageType), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *QQClient) UploadPrivateImage(target int64, img []byte) (*message.FriendImageElement, error) {
|
func (c *QQClient) UploadPrivateImage(target int64, img []byte) (*message.FriendImageElement, error) {
|
||||||
|
@ -77,6 +77,8 @@ func (e *GroupImageElement) Pack() (r []*msg.Elem) {
|
|||||||
Useful: 1,
|
Useful: 1,
|
||||||
//Origin: 1,
|
//Origin: 1,
|
||||||
BizType: 5,
|
BizType: 5,
|
||||||
|
Width: e.Width,
|
||||||
|
Height: e.Height,
|
||||||
FileId: int32(e.FileId),
|
FileId: int32(e.FileId),
|
||||||
FilePath: e.ImageId,
|
FilePath: e.ImageId,
|
||||||
ImageType: e.ImageType,
|
ImageType: e.ImageType,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user