Adding trim operation.

Closes #22

Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
This commit is contained in:
Yoan Blanc 2017-09-12 10:36:34 -04:00
parent b35675c245
commit c1f2667c0f
No known key found for this signature in database
GPG key ID: 6058CF4574298812
8 changed files with 64 additions and 5 deletions

16
vips.go
View file

@ -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])