mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-09 07:28:44 -07:00
Handle 16-bit PNGs
This commit is contained in:
parent
fd796251aa
commit
31a54299fb
3 changed files with 16 additions and 15 deletions
17
resize.go
17
resize.go
|
|
@ -112,11 +112,8 @@ func Resize(buf []byte, o Options) ([]byte, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Flatten image on a background, if necessary
|
||||
image, err = imageFlatten(image, imageType, o)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Only flatten PNG for now
|
||||
flatten := imageType == PNG && o.Background != ColorBlack
|
||||
|
||||
saveOptions := vipsSaveOptions{
|
||||
Quality: o.Quality,
|
||||
|
|
@ -125,6 +122,8 @@ func Resize(buf []byte, o Options) ([]byte, error) {
|
|||
Interlace: o.Interlace,
|
||||
NoProfile: o.NoProfile,
|
||||
Interpretation: o.Interpretation,
|
||||
Flatten: flatten,
|
||||
Background: o.Background,
|
||||
}
|
||||
|
||||
// Finally get the resultant buffer
|
||||
|
|
@ -325,14 +324,6 @@ func watermakImage(image *C.VipsImage, w Watermark) (*C.VipsImage, error) {
|
|||
return image, nil
|
||||
}
|
||||
|
||||
func imageFlatten(image *C.VipsImage, imageType ImageType, o Options) (*C.VipsImage, error) {
|
||||
// Only PNG images are supported for now
|
||||
if imageType != PNG || o.Background == ColorBlack {
|
||||
return image, nil
|
||||
}
|
||||
return vipsFlattenBackground(image, o.Background)
|
||||
}
|
||||
|
||||
func zoomImage(image *C.VipsImage, zoom int) (*C.VipsImage, error) {
|
||||
if zoom == 0 {
|
||||
return image, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue