init: hgmj server initial commit

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 16:50:13 +08:00
co-authored by Claude Opus 4.7
commit 625e89c15d
1870 changed files with 254090 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
package common
import (
"bytes"
"image"
"io"
"net/http"
)
type PictureProp struct {
Size int `json:"size" bson:"size,omitempty"` // 单位:b
Width int `json:"height" bson:"height,omitempty"`
Height int `json:"width" bson:"width,omitempty"`
}
const ImgUrlHost = "http://image.lhexm.com/"
func GetPictureProp(imgURL string) PictureProp {
res, err := http.Get(imgURL)
if err != nil {
return PictureProp{}
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
return PictureProp{}
}
buf := bytes.NewBuffer(body)
cfg, _, err := image.DecodeConfig(buf)
if err != nil {
return PictureProp{}
}
return PictureProp{
Size: len(body),
Width: cfg.Width,
Height: cfg.Height,
}
}