dd add image size limit

This commit is contained in:
fumiama
2022-02-13 12:08:50 +08:00
parent 01abfab133
commit 6b2dd112a6
3 changed files with 7 additions and 18 deletions

View File

@@ -73,22 +73,7 @@ func init() {
}
// 避免图片过大,最大 1280*720
x := back.Bounds().Size().X
y := back.Bounds().Size().Y
hasChanged := false
if x > 1280 {
y = y * 1280 / x
x = 1280
hasChanged = true
}
if y > 720 {
x = x * 720 / y
y = 720
hasChanged = true
}
if hasChanged {
back = img.Size(back, x, y).Im
}
back = img.Limit(back, 1280, 720)
canvas := gg.NewContext(back.Bounds().Size().X, int(float64(back.Bounds().Size().Y)*1.7))
canvas.SetRGB(1, 1, 1)