Skip to content
Snippets Groups Projects
Commit 8c0285a0 authored by Travis Ralston's avatar Travis Ralston
Browse files

Fix AdjustProperties

parent 96f60005
No related branches found
No related tags found
No related merge requests found
......@@ -50,9 +50,8 @@ func GenerateThumbnail(imgStream io.ReadCloser, contentType string, width int, h
return nil, common.ErrMediaTooLarge
}
// TODO: Why does AdjustProperties even take `canAnimate` if it's always been hardcoded to `false`? (see git blame on this comment)
var shouldThumbnail bool
shouldThumbnail, width, height, _, method = u.AdjustProperties(w, h, width, height, animated, false, method)
shouldThumbnail, width, height, _, method = u.AdjustProperties(w, h, width, height, animated, method)
if !shouldThumbnail && dimensional {
return nil, common.ErrMediaDimensionsTooSmall
}
......
package u
func AdjustProperties(srcWidth int, srcHeight int, desiredWidth int, desiredHeight int, wantAnimated bool, canAnimate bool, method string) (bool, int, int, bool, string) {
func AdjustProperties(srcWidth int, srcHeight int, desiredWidth int, desiredHeight int, wantAnimated bool, method string) (bool, int, int, bool, string) {
aspectRatio := float32(srcHeight) / float32(srcWidth)
targetAspectRatio := float32(desiredHeight) / float32(desiredWidth)
if aspectRatio == targetAspectRatio {
......@@ -11,8 +11,6 @@ func AdjustProperties(srcWidth int, srcHeight int, desiredWidth int, desiredHeig
if srcWidth <= desiredWidth && srcHeight <= desiredHeight {
if wantAnimated {
return true, srcWidth, srcHeight, true, method
} else if canAnimate {
return true, srcWidth, srcHeight, false, method
} else {
return false, desiredWidth, desiredHeight, false, method
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment