Skip to content

Commit

Permalink
fix: change to feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
KararTY committed Jul 17, 2021
1 parent f48bb58 commit 7a14d81
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/thumbnail/thumbnail_unix.go
Expand Up @@ -47,11 +47,11 @@ func buildThumbnailByteArray(inputBuf []byte, resp *http.Response) ([]byte, erro
outputImg := make([]byte, 2*1024*1024)

// lilliput has the height & width values in int, which means we're converting uint to int.
maxThumbnailSizeInt := int(cfg.MaxThumbnailSize)
maxThumbnailSize := int(cfg.MaxThumbnailSize)

// We don't need to resize image nor does it need to be passed through lilliput.
// Only resize if the original image has bigger dimensions than maxThumbnailSize
if newWidth < maxThumbnailSizeInt && newHeight < maxThumbnailSizeInt {
if newWidth < maxThumbnailSize && newHeight < maxThumbnailSize {
return inputBuf, nil
}

Expand All @@ -63,20 +63,20 @@ func buildThumbnailByteArray(inputBuf []byte, resp *http.Response) ([]byte, erro
*/

// Preserve aspect ratio
if newWidth > maxThumbnailSizeInt {
newHeight = newHeight * maxThumbnailSizeInt / newWidth
if newWidth > maxThumbnailSize {
newHeight = newHeight * maxThumbnailSize / newWidth
if newHeight < 1 {
newHeight = 1
}
newWidth = maxThumbnailSizeInt
newWidth = maxThumbnailSize
}

if newHeight > maxThumbnailSizeInt {
newWidth = newWidth * maxThumbnailSizeInt / newHeight
if newHeight > maxThumbnailSize {
newWidth = newWidth * maxThumbnailSize / newHeight
if newWidth < 1 {
newWidth = 1
}
newHeight = maxThumbnailSizeInt
newHeight = maxThumbnailSize
}

opts := &lilliput.ImageOptions{
Expand Down

0 comments on commit 7a14d81

Please sign in to comment.