mirror of https://github.com/talgo-cloud/bimg.git
parent
885b315035
commit
d471c49348
@ -1,12 +1,46 @@
|
||||
package bimg
|
||||
|
||||
/*
|
||||
#cgo pkg-config: vips
|
||||
#include "vips/vips.h"
|
||||
*/
|
||||
import "C"
|
||||
|
||||
type Image struct {
|
||||
buf []byte
|
||||
image *C.struct__VipsImage
|
||||
buffer []byte
|
||||
}
|
||||
|
||||
func (i *Image) Resize(width int, height int) ([]byte, error) {
|
||||
options := Options{
|
||||
Width: width,
|
||||
Height: height,
|
||||
}
|
||||
return Resize(i.buffer, options)
|
||||
}
|
||||
|
||||
func (i *Image) Extract(top int, left int, width int, height int) ([]byte, error) {
|
||||
options := Options{
|
||||
Width: width,
|
||||
Height: height,
|
||||
Top: top,
|
||||
Left: left,
|
||||
}
|
||||
return Resize(i.buffer, options)
|
||||
}
|
||||
|
||||
func (i *Image) Rotate(degrees Angle) ([]byte, error) {
|
||||
options := Options{Rotate: degrees}
|
||||
return Resize(i.buffer, options)
|
||||
}
|
||||
|
||||
func (i *Image) Flip() ([]byte, error) {
|
||||
options := Options{Flip: VERTICAL}
|
||||
return Resize(i.buffer, options)
|
||||
}
|
||||
|
||||
func (i *Image) Flop() ([]byte, error) {
|
||||
options := Options{Flip: HORIZONTAL}
|
||||
return Resize(i.buffer, options)
|
||||
}
|
||||
|
||||
func (i *Image) Type() string {
|
||||
return DetermineImageTypeName(i.buffer)
|
||||
}
|
||||
|
||||
func NewImage(buf []byte) *Image {
|
||||
return &Image{buf}
|
||||
}
|
||||
|
||||
Loading…
Reference in new issue