From cdbd68f34febffb5e2be86daf65cf4fe99189902 Mon Sep 17 00:00:00 2001 From: Jason Summers Date: Tue, 27 Nov 2012 20:49:01 -0500 Subject: [PATCH] Improve the way the new canvas size is calculated If both dimensions are given, always use those dimensions, avoiding roundoff error. If only one dimension is given, slightly prefer rounding the other dimension up, to rounding it down. --- resize.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resize.go b/resize.go index 7fd2ec9..2d4051a 100644 --- a/resize.go +++ b/resize.go @@ -64,7 +64,7 @@ func Resize(width, height uint, img image.Image, interp InterpolationFunction) i scaleX, scaleY := calcFactors(width, height, oldWidth, oldHeight) t := Trans2{scaleX, 0, float32(oldBounds.Min.X), 0, scaleY, float32(oldBounds.Min.Y)} - resizedImg := image.NewRGBA64(image.Rect(0, 0, int(oldWidth/scaleX), int(oldHeight/scaleY))) + resizedImg := image.NewRGBA64(image.Rect(0, 0, int(0.7+oldWidth/scaleX), int(0.7+oldHeight/scaleY))) b := resizedImg.Bounds() n := numJobs(b.Dy())