-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathinterface.go
39 lines (37 loc) · 2.22 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package processor
import "image"
// Processor interface for performing operations on image bytes
type Processor interface {
// Crop takes an image.Image, width, height and a Point and returns the cropped image
Crop(image image.Image, width, height int, point Point) image.Image
// Resize takes an image.Image, width and height and returns the re-sized image
Resize(image image.Image, width, height int) image.Image
// Scale takes an input image, width and height and returns the re-sized
// image without maintaining the original aspect ratio
Scale(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 by the specified
// radius(<=1000) or error radius must be larger than 0
Blur(image image.Image, radius float64) 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)
// 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.
Flip(image image.Image, mode string) image.Image
// Rotate takes an input image and returns a image rotated by the specified degrees.
// The rotation is applied clockwise, and fractional angles are supported.
Rotate(image image.Image, angle float64) image.Image
// Decode takes a byte array and returns the image, extension, and error
Decode(data []byte) (img image.Image, format string, err error)
// Encode takes an image and extension and return the encoded byte array or error
Encode(img image.Image, format string) ([]byte, error)
// FixOrientation takes an image and it's EXIF orientation (if exist)
// and returns the image with its EXIF orientation fixed
FixOrientation(img image.Image, orientation int) image.Image
// Overlay takes an input byte array as the base image and
// an array of OverlayAttrs to be placed as overlays to the base image
Overlay(base []byte, overlays []*OverlayAttrs) ([]byte, error)
}