summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nfnt/resize/resize.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-09-06 21:53:33 +0200
committerGitHub <noreply@github.com>2020-09-06 20:53:33 +0100
commitf7b3e0602603fda5d8a9b8eb65e0975af7cbe3bc (patch)
tree51e69fc451b94a783590f9349cd2f0325e6231ee /vendor/github.com/nfnt/resize/resize.go
parent332dbe73935ba960d8769bfc20b8d275922e4137 (diff)
downloadgitea-f7b3e0602603fda5d8a9b8eb65e0975af7cbe3bc.tar.gz
gitea-f7b3e0602603fda5d8a9b8eb65e0975af7cbe3bc.zip
Fix Avatar Resize (resize algo NearestNeighbor -> Bilinear) (#12745)
* Update Vendor github.com/nfnt/resize * switch resize algo NearestNeighbor -> Bilinear
Diffstat (limited to 'vendor/github.com/nfnt/resize/resize.go')
-rw-r--r--vendor/github.com/nfnt/resize/resize.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/vendor/github.com/nfnt/resize/resize.go b/vendor/github.com/nfnt/resize/resize.go
index 57bd1fcd03..0d7fbf69a9 100644
--- a/vendor/github.com/nfnt/resize/resize.go
+++ b/vendor/github.com/nfnt/resize/resize.go
@@ -78,6 +78,7 @@ var blur = 1.0
// If one of the parameters width or height is set to 0, its size will be calculated so that
// the aspect ratio is that of the originating image.
// The resizing algorithm uses channels for parallel computation.
+// If the input image has width or height of 0, it is returned unchanged.
func Resize(width, height uint, img image.Image, interp InterpolationFunction) image.Image {
scaleX, scaleY := calcFactors(width, height, float64(img.Bounds().Dx()), float64(img.Bounds().Dy()))
if width == 0 {
@@ -92,6 +93,11 @@ func Resize(width, height uint, img image.Image, interp InterpolationFunction) i
return img
}
+ // Input image has no pixels
+ if img.Bounds().Dx() <= 0 || img.Bounds().Dy() <= 0 {
+ return img
+ }
+
if interp == NearestNeighbor {
return resizeNearest(width, height, scaleX, scaleY, img, interp)
}