From bc4eb130585bcace9e0ca0dbd0f2bded2ddd7d39 Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 9 Jun 2018 17:20:27 +1200 Subject: [PATCH] scaler: support Stretch --- config.go | 1 + scaler.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/config.go b/config.go index c0084cc..a71da8d 100644 --- a/config.go +++ b/config.go @@ -12,6 +12,7 @@ const ( FitOutside AspectFormat = 80 // Pad out with black bars to dimensions FitInside AspectFormat = 82 // Crop to dimensions + Stretch AspectFormat = 83 // Doesn't preserve aspect ratio NearestNeighbour ScaleFormat = 120 BilinearFast ScaleFormat = 121 diff --git a/scaler.go b/scaler.go index def2867..17e15ac 100644 --- a/scaler.go +++ b/scaler.go @@ -52,6 +52,10 @@ func (this *DirectThumbnailer) scaleImage(src image.Image) (image.Image, error) srcCopyPosition = image.Rect(offsetX, offsetY, srcSmallestDim+offsetX, srcSmallestDim+offsetY) destCopyPosition = image.Rect(0, 0, this.cfg.Width, this.cfg.Height) + case Stretch: + srcCopyPosition = src.Bounds() + destCopyPosition = image.Rect(0, 0, this.cfg.Width, this.cfg.Height) + default: return nil, ErrInvalidOption }