mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-11 00:10:27 -07:00
feat(#19): maximum image size
This commit is contained in:
parent
bfe0e700ce
commit
abd6679f58
2 changed files with 8 additions and 1 deletions
|
|
@ -6,7 +6,10 @@ package bimg
|
|||
*/
|
||||
import "C"
|
||||
|
||||
const QUALITY = 80
|
||||
const (
|
||||
QUALITY = 80
|
||||
MAX_SIZE = 16383
|
||||
)
|
||||
|
||||
type Gravity int
|
||||
|
||||
|
|
|
|||
4
vips.go
4
vips.go
|
|
@ -113,6 +113,10 @@ func vipsExtract(image *C.struct__VipsImage, left, top, width, height int) (*C.s
|
|||
var buf *C.struct__VipsImage
|
||||
defer C.g_object_unref(C.gpointer(image))
|
||||
|
||||
if width > MAX_SIZE || height > MAX_SIZE {
|
||||
return nil, errors.New("Maximum image size exceeded")
|
||||
}
|
||||
|
||||
err := C.vips_extract_area_bridge(image, &buf, C.int(left), C.int(top), C.int(width), C.int(height))
|
||||
if err != 0 {
|
||||
return nil, catchVipsError()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue