Documentation ¶
Index ¶
- Constants
- Variables
- func Color2Hex(c color.Color) string
- func GetImageType(bytes []byte) (ext string, mime string, decoder func(r io.Reader) (image.Image, error), ...)
- func Image2RGBA(img image.Image) *image.RGBA
- func NormalizeKernel(kernel [][]float64)
- type FlipType
- type Image
- func Canvas(width, height int, fillColor ...color.Color) *Image
- func Load(source any) *Image
- func LoadFromBase64(base64Str string) (i *Image)
- func LoadFromFile(file *os.File) (i *Image)
- func LoadFromImage(img image.Image) (i *Image)
- func LoadFromPath(path string) (i *Image)
- func LoadFromUrl(url string) (i *Image)
- func (i *Image) Blur(ksize int) *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) ImageFilter(kernel [][]float64) *Image
- func (i *Image) ImageFilterFast(kernel [][]float64) *Image
- func (i *Image) Insert(source any, 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) Mime() 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) RadiusBorder(radius float64) *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) 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 ¶
const (
TopLeft = iota
)
Variables ¶
var ( ErrFileNotSupport = errors.New("file not support") ErrSourceImageIsNil = errors.New("imgo load source image is nil") ErrSourceNotSupport = errors.New("imgo load source not support") ErrSourceStringIsEmpty = errors.New("imgo load source string is empty") ErrSourceImageNotSupport = errors.New("imgo load source image not support") ErrSaveImageFormatNotSupport = errors.New("save image format not support") )
Functions ¶
func GetImageType ¶
func GetImageType(bytes []byte) (ext string, mime string, decoder func(r io.Reader) (image.Image, error), err error)
GetImageType returns the extension, mimetype and corresponding decoder function of the image. It judges the image by its first several bytes called magic number.
func Image2RGBA ¶
Image2RGBA converts an image to RGBA.
func NormalizeKernel ¶
func NormalizeKernel(kernel [][]float64)
NormalizeKernel normalizes a kernel.
Types ¶
type Image ¶
type Image struct { Error error // contains filtered or unexported fields }
func Load ¶
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 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) 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) ImageFilter ¶
ImageFilter returns a filtered image.
func (*Image) ImageFilterFast ¶
ImageFilterFast returns a filtered image with Goroutine.
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) RadiusBorder ¶
RadiusBorder draws a border around the image using the given radius.
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.
type ImageManager ¶
type ImageManager struct { }