mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-09 15:38:13 -07:00
Fix for memory issue when watermarking images
This commit is contained in:
parent
7cb8aa33c4
commit
ff7970929b
4 changed files with 45 additions and 117 deletions
12
vips.go
12
vips.go
|
|
@ -596,16 +596,16 @@ func max(x int) int {
|
|||
return int(math.Max(float64(x), 0))
|
||||
}
|
||||
|
||||
func vipsDrawWatermark(image *C.VipsImage, watermark *C.VipsImage, o WatermarkImage) (*C.VipsImage, error) {
|
||||
func vipsDrawWatermark(image *C.VipsImage, o WatermarkImage) (*C.VipsImage, error) {
|
||||
var out *C.VipsImage
|
||||
|
||||
if !vipsHasAlpha(image) {
|
||||
C.vips_add_band(image, &image, C.double(255.0))
|
||||
watermark, _, e := vipsRead(o.Buf)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
|
||||
if !vipsHasAlpha(watermark) {
|
||||
C.vips_add_band(watermark, &watermark, C.double(255.0))
|
||||
}
|
||||
defer C.g_object_unref(C.gpointer(image))
|
||||
defer C.g_object_unref(C.gpointer(watermark))
|
||||
|
||||
opts := vipsWatermarkImageOptions{C.int(o.Left), C.int(o.Top), C.float(o.Opacity)}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue