|
|
|
@ -112,8 +112,11 @@ func Resize(buf []byte, o Options) ([]byte, error) {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Only flatten PNG for now
|
|
|
|
// Flatten image on a background, if necessary
|
|
|
|
flatten := imageType == PNG && o.Background != ColorBlack
|
|
|
|
image, err = imageFlatten(image, imageType, o)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
saveOptions := vipsSaveOptions{
|
|
|
|
saveOptions := vipsSaveOptions{
|
|
|
|
Quality: o.Quality,
|
|
|
|
Quality: o.Quality,
|
|
|
|
@ -122,8 +125,6 @@ func Resize(buf []byte, o Options) ([]byte, error) {
|
|
|
|
Interlace: o.Interlace,
|
|
|
|
Interlace: o.Interlace,
|
|
|
|
NoProfile: o.NoProfile,
|
|
|
|
NoProfile: o.NoProfile,
|
|
|
|
Interpretation: o.Interpretation,
|
|
|
|
Interpretation: o.Interpretation,
|
|
|
|
Flatten: flatten,
|
|
|
|
|
|
|
|
Background: o.Background,
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Finally get the resultant buffer
|
|
|
|
// Finally get the resultant buffer
|
|
|
|
@ -324,6 +325,14 @@ func watermakImage(image *C.VipsImage, w Watermark) (*C.VipsImage, error) {
|
|
|
|
return image, nil
|
|
|
|
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) {
|
|
|
|
func zoomImage(image *C.VipsImage, zoom int) (*C.VipsImage, error) {
|
|
|
|
if zoom == 0 {
|
|
|
|
if zoom == 0 {
|
|
|
|
return image, nil
|
|
|
|
return image, nil
|
|
|
|
|