Documentation ¶
Index ¶
- Variables
- func Color2Hex(c color.Color) string
- func GetImageType(bytes []byte) (ext string, mimetype string, decoder func(r io.Reader) (image.Image, error), ...)
- func Image2RGBA(img image.Image) *image.RGBA
- type FlipType
- type Image
- func Canvas(width, height int, fillColor ...color.Color) *Image
- func Load(source interface{}) *Image
- func LoadFromBase64(base64Str string) (i *Image)
- func LoadFromFile(file *os.File) (i *Image)
- func LoadFromImage(img image.Image) (i *Image)
- func LoadFromImgo(i *Image) *Image
- func LoadFromPath(path string) (i *Image)
- func LoadFromUrl(url string) (i *Image)
- func (i *Image) Blur(ksize int) *Image
- func (i *Image) BorderRadius(radius float64) *Image
- func (i Image) Bounds() image.Rectangle
- func (i *Image) Circle(x, y, radius int, c color.Color) *Image
- func (i *Image) Crop(x, y, width, height int) *Image
- func (i *Image) Ellipse(x, y, width, height int, c color.Color) *Image
- func (i Image) Extension() string
- func (i Image) Filesize() int64
- func (i *Image) Flip(flipType FlipType) *Image
- func (i *Image) GaussianBlur(ksize int, sigma float64) *Image
- func (i *Image) Grayscale() *Image
- func (i Image) Height() int
- func (i Image) HttpHandler(w http.ResponseWriter, r *http.Request)
- func (i *Image) Insert(source interface{}, x, y int) *Image
- func (i *Image) Line(x1, y1, x2, y2 int, c color.Color, width ...int) *Image
- func (i *Image) MainColor() (res color.RGBA)
- func (i Image) Mimetype() string
- func (i *Image) Mosaic(size, x1, y1, x2, y2 int) *Image
- func (i Image) PickColor(x, y int) (res color.RGBA)
- func (i *Image) Pixel(x, y int, c color.Color) *Image
- func (i *Image) Pixelate(size int) *Image
- func (i *Image) Rectangle(x, y, width, height int, c color.Color) *Image
- func (i *Image) Resize(width, height int) *Image
- func (i *Image) Rotate(angle int) *Image
- func (i *Image) Save(path string, quality ...int) *Image
- func (i Image) String() string
- func (i *Image) Text(label string, x, y int, fontPath string, fontColor color.Color, ...) *Image
- func (i *Image) Text2(label string, x, y int, fontBytes []byte, fontColor color.Color, ...) *Image
- func (i *Image) Thumbnail(width, height int) *Image
- func (i Image) ToBase64() string
- func (i Image) ToImage() image.Image
- func (i Image) Width() int
- type ImageManager
- type Radius
Constants ¶
This section is empty.
Variables ¶
var ( ErrSourceImageIsNil = errors.New("source image is nil") ErrSourceNotSupport = errors.New("source not support") ErrSourceStringIsEmpty = errors.New("source string is empty") ErrSourceImageNotSupport = errors.New("source image not support") ErrSaveImageFormatNotSupport = errors.New("save image format not support") )
Functions ¶
Types ¶
type Image ¶
type Image struct { Error error // contains filtered or unexported fields }
func Load ¶
func Load(source interface{}) *Image
Load an image from source. source can be a file path, a URL, a base64 encoded string, an *os.File, an image.Image or a byte slice.
func LoadFromBase64 ¶
LoadFromBase64 loads an image from a base64 encoded string.
func LoadFromFile ¶
LoadFromFile loads an image from a file.
func LoadFromImage ¶
LoadFromImage loads an image from an instance of image.Image.
func LoadFromImgo ¶
LoadFromImgo loads an image from an instance of Image.
func LoadFromPath ¶
LoadFromPath loads an image from a path.
func LoadFromUrl ¶
LoadFromUrl loads an image when the source is an url.
func (*Image) Blur ¶
Blur returns a blurred image. ksize is filter kernel size, it must be a odd number.
func (*Image) BorderRadius ¶
BorderRadius draws rounded corners on the image with given radius.
func (*Image) Circle ¶
Circle draws a circle at given center coordinate (x, y) with given radius and color.
func (*Image) Crop ¶
Crop Cut out a rectangular part of the current image with given width and height.
func (*Image) Ellipse ¶
Ellipse draws an ellipse at given center coordinate (x, y) with given width and height and color.
func (Image) Filesize ¶
Filesize returns the filesize of the image, if instance is initiated from an actual file.
func (*Image) GaussianBlur ¶
GaussianBlur returns a blurred image. ksize is Gaussian kernel size sigma is Gaussian kernel standard deviation.
func (Image) HttpHandler ¶
func (i Image) HttpHandler(w http.ResponseWriter, r *http.Request)
HttpHandler responds the image as an HTTP handler.
func (*Image) Insert ¶
Insert inserts source into the image at given (x, y) coordinate. source can be a file path, a URL, a base64 encoded string, an *os.File, an image.Image, a byte slice or an *Image.
func (*Image) Line ¶
Line draws a line from (x1, y1) to (x2, y2) with given color. TODO: width is not working yet.
func (*Image) Mosaic ¶
Mosaic apply mosaic filter to the image in given rectangle that (x1, y1) and (x2, y2) are the top-left and bottom-right coordinates of the rectangle. size is the size of the pixel.
func (*Image) Pixelate ¶
Pixelate apply pixelation filter to the image. size is the size of the pixel.
func (*Image) Rectangle ¶
Rectangle draws a rectangle at given coordinate (x, y) with given width and height and color.
func (*Image) Save ¶
Save saves the image to the specified path. Only png, jpeg, jpg, tiff and bmp extensions are supported. path is the path the image will be saved to. quality is the quality of the image, between 1 and 100, default is 100, and is only used for jpeg images.
func (*Image) Text ¶
func (i *Image) Text(label string, x, y int, fontPath string, fontColor color.Color, fontSize float64, dpi float64) *Image
Text write a text string to the image at given (x, y) coordinate.
func (*Image) Text2 ¶
func (i *Image) Text2(label string, x, y int, fontBytes []byte, fontColor color.Color, fontSize float64, dpi float64) *Image
添加从byte数组读字体,内嵌字体场景
type ImageManager ¶
type ImageManager struct { }