mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-18 03:36:33 -07:00
Adding trim operation.
Closes #22 Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
This commit is contained in:
parent
b35675c245
commit
c1f2667c0f
8 changed files with 64 additions and 5 deletions
16
vips.go
16
vips.go
|
|
@ -503,6 +503,22 @@ func vipsSmartCrop(image *C.VipsImage, width, height int) (*C.VipsImage, error)
|
|||
return buf, nil
|
||||
}
|
||||
|
||||
func vipsTrim(image *C.VipsImage) (int, int, int, int, error) {
|
||||
defer C.g_object_unref(C.gpointer(image))
|
||||
|
||||
top := C.int(0)
|
||||
left := C.int(0)
|
||||
width := C.int(0)
|
||||
height := C.int(0)
|
||||
|
||||
err := C.vips_find_trim_bridge(image, &top, &left, &width, &height)
|
||||
if err != 0 {
|
||||
return 0, 0, 0, 0, catchVipsError()
|
||||
}
|
||||
|
||||
return int(top), int(left), int(width), int(height), nil
|
||||
}
|
||||
|
||||
func vipsShrinkJpeg(buf []byte, input *C.VipsImage, shrink int) (*C.VipsImage, error) {
|
||||
var image *C.VipsImage
|
||||
var ptr = unsafe.Pointer(&buf[0])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue