From 9130be05759956d28acfa8a36be8abbd554e6e99 Mon Sep 17 00:00:00 2001 From: Sajjad Rad Date: Sat, 25 Sep 2021 16:00:22 +0300 Subject: [PATCH] feat: add resize method to image processor --- image/image.go | 1 + image/imaging.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/image/image.go b/image/image.go index d81bb93..39c2ae1 100644 --- a/image/image.go +++ b/image/image.go @@ -7,6 +7,7 @@ import ( type Processor interface { CropCenter(img image.Image, width, height int) *image.Image + Resize(img image.Image, width, height int) *image.Image } func Decode(name string) (*image.Image, error) { diff --git a/image/imaging.go b/image/imaging.go index d48e129..743d729 100644 --- a/image/imaging.go +++ b/image/imaging.go @@ -11,3 +11,8 @@ func (i *Imaging) CropCenter(img image.Image, width, height int) *image.Image { img = imaging.Fill(img, width, height, imaging.Center, imaging.Lanczos) return &img } + +func (i *Imaging) Resize(img image.Image, width, height int) *image.Image { + img = imaging.Resize(img, width, height, imaging.Lanczos) + return &img +}