diff --git a/weed/images/resizing.go b/weed/images/resizing.go index aa6574eb0..0e4a7b9bc 100644 --- a/weed/images/resizing.go +++ b/weed/images/resizing.go @@ -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 {