Add the option to use background and threshold options on trim

This commit is contained in:
Martti Leppänen 2017-11-09 15:32:58 -05:00
parent 1a5477aae5
commit 58bc9312b6
5 changed files with 42 additions and 5 deletions

View file

@ -503,7 +503,7 @@ func vipsSmartCrop(image *C.VipsImage, width, height int) (*C.VipsImage, error)
return buf, nil
}
func vipsTrim(image *C.VipsImage) (int, int, int, int, error) {
func vipsTrim(image *C.VipsImage, background Color, threshold float32) (int, int, int, int, error) {
defer C.g_object_unref(C.gpointer(image))
top := C.int(0)
@ -511,7 +511,10 @@ func vipsTrim(image *C.VipsImage) (int, int, int, int, error) {
width := C.int(0)
height := C.int(0)
err := C.vips_find_trim_bridge(image, &top, &left, &width, &height)
err := C.vips_find_trim_bridge(image,
&top, &left, &width, &height,
C.double(background.R), C.double(background.G), C.double(background.B),
C.double(threshold))
if err != 0 {
return 0, 0, 0, 0, catchVipsError()
}