|
|
|
@ -19,10 +19,17 @@ func Resized(ext string, data []byte, width, height int) (resized []byte, w int, |
|
|
|
|
|
|
|
dx := srcImage.Bounds().Dx() |
|
|
|
dy := srcImage.Bounds().Dy() |
|
|
|
if width/height > dx/dy { //定高
|
|
|
|
width = height * dx / dy |
|
|
|
} else if width/height < dx/dy { //定宽
|
|
|
|
|
|
|
|
if height == 0 { |
|
|
|
height = width * dy / dx |
|
|
|
} else if width == 0 { |
|
|
|
width = height * dx / dy |
|
|
|
} else { |
|
|
|
if width/height > dx/dy { //定高
|
|
|
|
width = height * dx / dy |
|
|
|
} else if width/height < dx/dy { //定宽
|
|
|
|
height = width * dy / dx |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if err == nil { |
|
|
|
|