From 125806e589a16eb18dbd3f8c36c088d43ce330e2 Mon Sep 17 00:00:00 2001 From: Tomas Aparicio Date: Sat, 4 Apr 2015 14:57:28 +0200 Subject: [PATCH] refactor(vips): check image type --- vips.go | 7 ++++++- vips.h | 6 ------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/vips.go b/vips.go index b464e9a..4d2a99d 100644 --- a/vips.go +++ b/vips.go @@ -60,8 +60,13 @@ func vipsFlip(image *C.struct__VipsImage, direction Direction) (*C.struct__VipsI func vipsRead(buf []byte) (*C.struct__VipsImage, error) { var image *C.struct__VipsImage + imageType := vipsImageType(buf) - debug("Format: %s", vipsImageType(buf)) + debug("Image format: %s", imageType) + + if imageType == UNKNOWN { + return nil, errors.New("Input buffer contains unsupported image format") + } // feed it length := C.size_t(len(buf)) diff --git a/vips.h b/vips.h index 9990c3d..1cffa24 100644 --- a/vips.h +++ b/vips.h @@ -2,12 +2,6 @@ #include #include -int -vips_initialize() -{ - return vips_init("bimg"); -}; - int vips_affine_interpolator(VipsImage *in, VipsImage **out, double a, double b, double c, double d, VipsInterpolate *interpolator) {