mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-07 21:48:13 -08:00
Check if there is an alpha channel before flattening
This commit is contained in:
parent
fc9b23852e
commit
7170832f93
1 changed files with 6 additions and 5 deletions
11
vips.go
11
vips.go
|
|
@ -274,13 +274,14 @@ func vipsFlattenBackground(image *C.VipsImage, background Color) (*C.VipsImage,
|
|||
C.double(background.B),
|
||||
}
|
||||
|
||||
err := C.vips_flatten_background_brigde(image, &outImage, (*C.double)(&backgroundC[0]))
|
||||
if int(err) != 0 {
|
||||
return nil, catchVipsError()
|
||||
}
|
||||
|
||||
if vipsHasAlpha(image) {
|
||||
err := C.vips_flatten_background_brigde(image, &outImage, (*C.double)(&backgroundC[0]))
|
||||
if int(err) != 0 {
|
||||
return nil, catchVipsError()
|
||||
}
|
||||
C.g_object_unref(C.gpointer(image))
|
||||
image = outImage
|
||||
}
|
||||
|
||||
return image, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue