mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-15 10:25:55 -07:00
Adding basic smartcrop support.
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
This commit is contained in:
parent
24d84e6d8c
commit
9c914467b3
7 changed files with 58 additions and 3 deletions
16
vips.go
16
vips.go
|
|
@ -456,6 +456,22 @@ func vipsExtract(image *C.VipsImage, left, top, width, height int) (*C.VipsImage
|
|||
return buf, nil
|
||||
}
|
||||
|
||||
func vipsSmartCrop(image *C.VipsImage, width, height int) (*C.VipsImage, error) {
|
||||
var buf *C.VipsImage
|
||||
defer C.g_object_unref(C.gpointer(image))
|
||||
|
||||
if width > MaxSize || height > MaxSize {
|
||||
return nil, errors.New("Maximum image size exceeded")
|
||||
}
|
||||
|
||||
err := C.vips_smartcrop_bridge(image, &buf, C.int(width), C.int(height))
|
||||
if err != 0 {
|
||||
return nil, catchVipsError()
|
||||
}
|
||||
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
func vipsShrinkJpeg(buf []byte, input *C.VipsImage, shrink int) (*C.VipsImage, error) {
|
||||
var image *C.VipsImage
|
||||
var ptr = unsafe.Pointer(&buf[0])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue