mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-09 07:28:44 -07:00
Add the option to use background and threshold options on trim
This commit is contained in:
parent
1a5477aae5
commit
58bc9312b6
5 changed files with 42 additions and 5 deletions
7
vips.go
7
vips.go
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue