From 2607ff223295faa9da26c7eb9e9be410c1c692c8 Mon Sep 17 00:00:00 2001 From: Tomas Aparicio Date: Wed, 8 Apr 2015 02:37:16 +0200 Subject: [PATCH] feat(image): pass gravity to crop --- image.go | 11 ++++++----- image_test.go | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/image.go b/image.go index c1bea8a..f979586 100644 --- a/image.go +++ b/image.go @@ -35,12 +35,13 @@ func (i *Image) Enlarge(width, height int) ([]byte, error) { return i.Process(options) } -// Crop an image by width and height -func (i *Image) Crop(width, height int) ([]byte, error) { +// Crop the image to the exact size specified +func (i *Image) Crop(width, height int, gravity Gravity) ([]byte, error) { options := Options{ - Width: width, - Height: height, - Crop: true, + Width: width, + Height: height, + Gravity: gravity, + Crop: true, } return i.Process(options) } diff --git a/image_test.go b/image_test.go index a152180..36666a9 100644 --- a/image_test.go +++ b/image_test.go @@ -49,7 +49,7 @@ func TestImageEnlarge(t *testing.T) { } func TestImageCrop(t *testing.T) { - buf, err := initImage("test.jpg").Crop(800, 600) + buf, err := initImage("test.jpg").Crop(800, 600, NORTH) if err != nil { t.Errorf("Cannot process the image: %#v", err) }