Merge pull request #206 from tstm/add-trim-options

Add the option to use background and threshold options on trim
This commit is contained in:
Tomás 2017-11-23 09:03:45 +01:00 committed by GitHub
commit 03f7d1fe04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 5 deletions

View file

@ -504,7 +504,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)
@ -512,7 +512,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()
}