mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-09-28 12:37:47 +02:00
42 lines
730 B
Go
42 lines
730 B
Go
package config
|
|
|
|
import "fmt"
|
|
|
|
type WebpPresetKind int
|
|
|
|
const (
|
|
WebpPresetDefault WebpPresetKind = iota
|
|
WebpPresetPhoto
|
|
WebpPresetPicture
|
|
WebpPresetDrawing
|
|
WebpPresetIcon
|
|
WebpPresetText
|
|
)
|
|
|
|
var WebpPresets = map[string]WebpPresetKind{
|
|
"default": WebpPresetDefault,
|
|
"photo": WebpPresetPhoto,
|
|
"picture": WebpPresetPicture,
|
|
"drawing": WebpPresetDrawing,
|
|
"icon": WebpPresetIcon,
|
|
"text": WebpPresetText,
|
|
}
|
|
|
|
func (wp WebpPresetKind) String() string {
|
|
for k, v := range WebpPresets {
|
|
if v == wp {
|
|
return k
|
|
}
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func (wp WebpPresetKind) MarshalJSON() ([]byte, error) {
|
|
for k, v := range WebpPresets {
|
|
if v == wp {
|
|
return []byte(fmt.Sprintf("%q", k)), nil
|
|
}
|
|
}
|
|
return []byte("null"), nil
|
|
}
|