mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-09 07:28:44 -07:00
feat(#15): add benchmark tests
This commit is contained in:
parent
16576f49c9
commit
bfe0e700ce
5 changed files with 77 additions and 36 deletions
22
type.go
22
type.go
|
|
@ -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"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue