forked from forgejo/forgejo
Fix Avatar Resize (resize algo NearestNeighbor -> Bilinear) (#12745)
* Update Vendor github.com/nfnt/resize * switch resize algo NearestNeighbor -> Bilinear
This commit is contained in:
parent
332dbe7393
commit
f7b3e06026
8 changed files with 298 additions and 130 deletions
6
vendor/github.com/nfnt/resize/resize.go
generated
vendored
6
vendor/github.com/nfnt/resize/resize.go
generated
vendored
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue