Skip to content

Commit

Permalink
add Blur function to processor
Browse files Browse the repository at this point in the history
  • Loading branch information
kavishgambhir committed Aug 17, 2019
1 parent 6cb5ffa commit 87aefdc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/processor/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ type Processor interface {
Resize(image image.Image, width, height int) image.Image
// GrayScale takes an input byte array and returns the grayscaled byte array or error
GrayScale(image image.Image) image.Image
// Blur takes an input byte array and returns the blurred byte array or error
Blur(image image.Image) image.Image
// Watermark takes an input byte array, overlay byte array and opacity value
// and returns the watermarked image bytes or error
Watermark(base []byte, overlay []byte, opacity uint8) ([]byte, error)
Expand Down
6 changes: 6 additions & 0 deletions pkg/processor/native/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"image/draw"
"strings"

"github.com/anthonynsimon/bild/blur"
"github.com/anthonynsimon/bild/clone"
"github.com/anthonynsimon/bild/effect"
"github.com/anthonynsimon/bild/transform"
Expand Down Expand Up @@ -86,6 +87,11 @@ func (bp *BildProcessor) GrayScale(img image.Image) image.Image {
return effect.GrayscaleWithWeights(img, 0.299, 0.587, 0.114)
}

// Blur takes an input image and blur radius and returns the Gausian blurred image
func (bp *BildProcessor) Blur(img image.Image, radius float64) image.Image {
return blur.Gaussian(img,radius)
}

// Flip takes an input image and returns the image flipped. The direction of flip
// is determined by the specified mode - 'v' for a vertical flip, 'h' for a
// horizontal flip and 'vh'(or 'hv') for both.
Expand Down

0 comments on commit 87aefdc

Please sign in to comment.