mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-13 09:20:29 -07:00
fix(vips): check magick type support
This commit is contained in:
parent
dfd6e8fe2d
commit
8e0592bb9a
2 changed files with 7 additions and 4 deletions
6
type.go
6
type.go
|
|
@ -106,15 +106,15 @@ func IsImageTypeSupportedByVips(t ImageType) bool {
|
||||||
imageMutex.RLock()
|
imageMutex.RLock()
|
||||||
|
|
||||||
// Discover supported image types and cache the result
|
// Discover supported image types and cache the result
|
||||||
itShouldDiscovery := len(SupportedImageTypes) == 0
|
itShouldDiscover := len(SupportedImageTypes) == 0
|
||||||
if itShouldDiscovery {
|
if itShouldDiscover {
|
||||||
imageMutex.RUnlock()
|
imageMutex.RUnlock()
|
||||||
discoverSupportedImageTypes()
|
discoverSupportedImageTypes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if image type is actually supported
|
// Check if image type is actually supported
|
||||||
isSupported, ok := SupportedImageTypes[t]
|
isSupported, ok := SupportedImageTypes[t]
|
||||||
if !itShouldDiscovery {
|
if !itShouldDiscover {
|
||||||
imageMutex.RUnlock()
|
imageMutex.RUnlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
5
vips.go
5
vips.go
|
|
@ -161,6 +161,9 @@ func VipsIsTypeSupported(t ImageType) bool {
|
||||||
if t == TIFF {
|
if t == TIFF {
|
||||||
return int(C.vips_type_find_bridge(C.TIFF)) != 0
|
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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -512,7 +515,7 @@ func vipsImageType(buf []byte) ImageType {
|
||||||
if IsImageTypeSupportedByVips(SVG) && IsSVGImage(buf) {
|
if IsImageTypeSupportedByVips(SVG) && IsSVGImage(buf) {
|
||||||
return SVG
|
return SVG
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(readImageType(buf), "MagickBuffer") {
|
if IsImageTypeSupportedByVips(MAGICK) && strings.HasSuffix(readImageType(buf), "MagickBuffer") {
|
||||||
return MAGICK
|
return MAGICK
|
||||||
}
|
}
|
||||||
return UNKNOWN
|
return UNKNOWN
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue