From 8e0592bb9a5f169c19e0b29d96dfba8b0cc16b14 Mon Sep 17 00:00:00 2001 From: Tomas Aparicio Date: Thu, 29 Sep 2016 20:49:34 +0100 Subject: [PATCH] fix(vips): check magick type support --- type.go | 6 +++--- vips.go | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/type.go b/type.go index beb5b3d..dc92aca 100644 --- a/type.go +++ b/type.go @@ -106,15 +106,15 @@ func IsImageTypeSupportedByVips(t ImageType) bool { imageMutex.RLock() // Discover supported image types and cache the result - itShouldDiscovery := len(SupportedImageTypes) == 0 - if itShouldDiscovery { + itShouldDiscover := len(SupportedImageTypes) == 0 + if itShouldDiscover { imageMutex.RUnlock() discoverSupportedImageTypes() } // Check if image type is actually supported isSupported, ok := SupportedImageTypes[t] - if !itShouldDiscovery { + if !itShouldDiscover { imageMutex.RUnlock() } diff --git a/vips.go b/vips.go index 33ab442..a7d3b35 100644 --- a/vips.go +++ b/vips.go @@ -161,6 +161,9 @@ func VipsIsTypeSupported(t ImageType) bool { if t == TIFF { return int(C.vips_type_find_bridge(C.TIFF)) != 0 } + if t == MAGICK { + return int(C.vips_type_find_bridge(C.MAGICK)) != 0 + } return false } @@ -512,7 +515,7 @@ func vipsImageType(buf []byte) ImageType { if IsImageTypeSupportedByVips(SVG) && IsSVGImage(buf) { return SVG } - if strings.HasSuffix(readImageType(buf), "MagickBuffer") { + if IsImageTypeSupportedByVips(MAGICK) && strings.HasSuffix(readImageType(buf), "MagickBuffer") { return MAGICK } return UNKNOWN