- Adding a Background option when flattening out a transparent PNG

This commit is contained in:
Clement DAL PALU 2015-09-28 17:33:38 -07:00
parent ebb3688b44
commit e83c80c93c
5 changed files with 42 additions and 0 deletions

View file

@ -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,