Merge pull request #405 from igsr5/feat/#404-support-way-to-change–MaxSize

Implement getter and setter for MaxSize
master
Tom 4 years ago committed by GitHub
commit e2c40ee48a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,14 +5,32 @@ package bimg
#include "vips/vips.h"
*/
import "C"
import "errors"
const (
// Quality defines the default JPEG quality to be used.
Quality = 75
// MaxSize defines the maximum pixels width or height supported.
MaxSize = 16383
)
// maxSize defines maximum pixels width or height supported.
var maxSize = 16383
// MaxSize returns maxSize.
func MaxSize() int {
return maxSize
}
// SetMaxSize sets maxSize.
func SetMaxsize(s int) error {
if s <= 0 {
return errors.New("Size must be higher than zero.")
}
maxSize = s
return nil
}
// Gravity represents the image gravity value.
type Gravity int

@ -564,7 +564,7 @@ func vipsExtract(image *C.VipsImage, left, top, width, height int) (*C.VipsImage
var buf *C.VipsImage
defer C.g_object_unref(C.gpointer(image))
if width > MaxSize || height > MaxSize {
if width > maxSize || height > maxSize {
return nil, errors.New("Maximum image size exceeded")
}
@ -581,7 +581,7 @@ 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 {
if width > maxSize || height > maxSize {
return nil, errors.New("Maximum image size exceeded")
}

Loading…
Cancel
Save