feat(#15): add benchmark tests

This commit is contained in:
Tomas Aparicio 2015-04-07 23:23:42 +02:00
parent 16576f49c9
commit bfe0e700ce
5 changed files with 77 additions and 36 deletions

22
type.go
View file

@ -11,14 +11,27 @@ const (
MAGICK
)
// Determines the image type format (jpeg, png, webp or tiff)
func DetermineImageType(buf []byte) ImageType {
return vipsImageType(buf)
}
// Determines the image type format by name (jpeg, png, webp or tiff)
func DetermineImageTypeName(buf []byte) string {
return getImageTypeName(vipsImageType(buf))
}
// Check if a given image type is supported
func IsTypeSupported(t ImageType) bool {
return t == JPEG || t == PNG || t == WEBP
}
// Check if a given image type name is supported
func IsTypeNameSupported(t string) bool {
return t == "jpeg" || t == "jpg" ||
t == "png" || t == "webp"
}
func getImageTypeName(code ImageType) string {
imageType := "unknown"
@ -42,12 +55,3 @@ func getImageTypeName(code ImageType) string {
return imageType
}
func IsTypeSupported(t ImageType) bool {
return t == JPEG || t == PNG || t == WEBP
}
func IsTypeNameSupported(t string) bool {
return t == "jpeg" || t == "jpg" ||
t == "png" || t == "webp"
}