瀏覽代碼

Bug fixed in Fit function

disintegration 13 年之前
父節點
當前提交
b1d1f6093d
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      imaging.go

+ 2 - 2
imaging.go

@@ -504,10 +504,10 @@ func Fit(img image.Image, maxW, maxH int) draw.Image {
 	var newW, newH int
 	if srcAspectRatio > maxAspectRatio {
 		newW = maxW
-		newH = int(srcAspectRatio / float64(newW))
+		newH = int(float64(newW) / srcAspectRatio)
 	} else {
 		newH = maxH
-		newW = int(srcAspectRatio * float64(newH))
+		newW = int(float64(newH) * srcAspectRatio)
 	}
 
 	return Resize(img, newW, newH)