Merge pull request #91 from h2non/master

Sync develop
master
Tomás Aparicio 10 years ago committed by GitHub
commit b6a09a5b80

@ -9,7 +9,7 @@ and it's typically 4x faster than using the quickest ImageMagick and GraphicsMag
If you're looking for an HTTP based image processing solution, see [imaginary](https://github.com/h2non/imaginary). If you're looking for an HTTP based image processing solution, see [imaginary](https://github.com/h2non/imaginary).
bimg was heavily inspired in [sharp](https://github.com/lovell/sharp), its homologous package built for [node.js](http://nodejs.org). bimg was heavily inspired in [sharp](https://github.com/lovell/sharp), its homologous package built for [node.js](http://nodejs.org). bimg is used in production environments for more than a year processing thousands of images per day.
**v1 notice**: `bimg` introduces some minor breaking changes in `v1` release. **v1 notice**: `bimg` introduces some minor breaking changes in `v1` release.
If you're using `gopkg.in`, you can still rely in the `v0` without worrying about breaking changes. If you're using `gopkg.in`, you can still rely in the `v0` without worrying about breaking changes.

@ -274,14 +274,15 @@ func vipsFlattenBackground(image *C.VipsImage, background Color) (*C.VipsImage,
C.double(background.B), C.double(background.B),
} }
err := C.vips_flatten_background_brigde(image, &outImage, (*C.double)(&backgroundC[0])) if vipsHasAlpha(image) {
if int(err) != 0 { err := C.vips_flatten_background_brigde(image, &outImage, (*C.double)(&backgroundC[0]))
return nil, catchVipsError() 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 return image, nil
} }
@ -317,7 +318,12 @@ func vipsSave(image *C.VipsImage, o vipsSaveOptions) ([]byte, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer C.g_object_unref(C.gpointer(tmpImage)) //When an image has an unsupported color space, vipsPreSave returns the pointer of the image passed to it unmodified.
//When this occurs, we must take care to not dereference the original image a second time;
//we may otherwise erroneously free the object twice
if tmpImage != image {
defer C.g_object_unref(C.gpointer(tmpImage))
}
length := C.size_t(0) length := C.size_t(0)
saveErr := C.int(0) saveErr := C.int(0)

Loading…
Cancel
Save