mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-13 01:10:29 -07:00
- Adding a Background option when flattening out a transparent PNG
This commit is contained in:
parent
ebb3688b44
commit
e83c80c93c
5 changed files with 42 additions and 0 deletions
|
|
@ -102,6 +102,15 @@ func Resize(buf []byte, o Options) ([]byte, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Flatten image on a background, if necessary
|
||||
black := Color{0, 0, 0}
|
||||
if imageType == PNG && o.Background != black {
|
||||
image, err = vipsFlatten(image, o.Background)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
saveOptions := vipsSaveOptions{
|
||||
Quality: o.Quality,
|
||||
Type: o.Type,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue