feat(#19): maximum image size

This commit is contained in:
Tomas Aparicio 2015-04-07 23:28:38 +02:00
parent bfe0e700ce
commit abd6679f58
2 changed files with 8 additions and 1 deletions

View file

@ -6,7 +6,10 @@ package bimg
*/
import "C"
const QUALITY = 80
const (
QUALITY = 80
MAX_SIZE = 16383
)
type Gravity int

View file

@ -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()