summaryrefslogtreecommitdiff
path: root/vendor/github.com/nfnt/resize/thumbnail.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-08-10 14:05:14 +0200
committerLibravatar GitHub <noreply@github.com>2022-08-10 14:05:14 +0200
commit91c8d5d20d9abee8113614ef49b1a626c76c16b4 (patch)
tree745d1b3df4b32b50bc098770d44e5f4f9f72311b /vendor/github.com/nfnt/resize/thumbnail.go
parent[bugfix] Fix placeholder typo in user panel (#745) (diff)
downloadgotosocial-91c8d5d20d9abee8113614ef49b1a626c76c16b4.tar.xz
[bugfix] Fix thumbnails not taking exif rotation into account (#746)
* use disintegration/imaging instead of nfnt/resize * update tests * use disintegration lib for thumbing (if necessary)
Diffstat (limited to 'vendor/github.com/nfnt/resize/thumbnail.go')
-rw-r--r--vendor/github.com/nfnt/resize/thumbnail.go55
1 files changed, 0 insertions, 55 deletions
diff --git a/vendor/github.com/nfnt/resize/thumbnail.go b/vendor/github.com/nfnt/resize/thumbnail.go
deleted file mode 100644
index 9efc246be..000000000
--- a/vendor/github.com/nfnt/resize/thumbnail.go
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-Copyright (c) 2012, Jan Schlicht <jan.schlicht@gmail.com>
-
-Permission to use, copy, modify, and/or distribute this software for any purpose
-with or without fee is hereby granted, provided that the above copyright notice
-and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
-OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
-TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
-THIS SOFTWARE.
-*/
-
-package resize
-
-import (
- "image"
-)
-
-// Thumbnail will downscale provided image to max width and height preserving
-// original aspect ratio and using the interpolation function interp.
-// It will return original image, without processing it, if original sizes
-// are already smaller than provided constraints.
-func Thumbnail(maxWidth, maxHeight uint, img image.Image, interp InterpolationFunction) image.Image {
- origBounds := img.Bounds()
- origWidth := uint(origBounds.Dx())
- origHeight := uint(origBounds.Dy())
- newWidth, newHeight := origWidth, origHeight
-
- // Return original image if it have same or smaller size as constraints
- if maxWidth >= origWidth && maxHeight >= origHeight {
- return img
- }
-
- // Preserve aspect ratio
- if origWidth > maxWidth {
- newHeight = uint(origHeight * maxWidth / origWidth)
- if newHeight < 1 {
- newHeight = 1
- }
- newWidth = maxWidth
- }
-
- if newHeight > maxHeight {
- newWidth = uint(newWidth * maxHeight / newHeight)
- if newWidth < 1 {
- newWidth = 1
- }
- newHeight = maxHeight
- }
- return Resize(newWidth, newHeight, img, interp)
-}