mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-09 15:38:13 -07:00
feat: support multiple outputs
This commit is contained in:
parent
d471c49348
commit
ef10d7d7ec
9 changed files with 220 additions and 58 deletions
17
type.go
17
type.go
|
|
@ -1,7 +1,9 @@
|
|||
package bimg
|
||||
|
||||
type ImageType int
|
||||
|
||||
const (
|
||||
UNKNOWN = iota
|
||||
UNKNOWN ImageType = iota
|
||||
JPEG
|
||||
WEBP
|
||||
PNG
|
||||
|
|
@ -9,7 +11,7 @@ const (
|
|||
MAGICK
|
||||
)
|
||||
|
||||
func DetermineImageType(buf []byte) int {
|
||||
func DetermineImageType(buf []byte) ImageType {
|
||||
return vipsImageType(buf)
|
||||
}
|
||||
|
||||
|
|
@ -28,7 +30,7 @@ func DetermineImageTypeName(buf []byte) string {
|
|||
imageType = "png"
|
||||
break
|
||||
case imageCode == TIFF:
|
||||
imageType = "png"
|
||||
imageType = "tiff"
|
||||
break
|
||||
case imageCode == MAGICK:
|
||||
imageType = "magick"
|
||||
|
|
@ -37,3 +39,12 @@ func DetermineImageTypeName(buf []byte) 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