mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-11 08:20:34 -07:00
Merge pull request #1 from blippar/check_alpha
Check for alpha channel before flattening PNG
This commit is contained in:
commit
45cfc1a75a
1 changed files with 7 additions and 6 deletions
13
vips.go
13
vips.go
|
|
@ -274,14 +274,15 @@ 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
|
||||
}
|
||||
|
||||
C.g_object_unref(C.gpointer(image))
|
||||
image = outImage
|
||||
|
||||
return image, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue