github.com/status-im/status-go@v1.1.0/images/type.go (about) 1 package images 2 3 import ( 4 "errors" 5 6 "github.com/status-im/status-go/protocol/protobuf" 7 ) 8 9 func GetProtobufImageFormat(buf []byte) protobuf.ImageFormat { 10 switch GetType(buf) { 11 case JPEG: 12 return protobuf.ImageFormat_JPEG 13 case PNG: 14 return protobuf.ImageFormat_PNG 15 case GIF: 16 return protobuf.ImageFormat_GIF 17 case WEBP: 18 return protobuf.ImageFormat_WEBP 19 default: 20 return protobuf.ImageFormat_UNKNOWN_IMAGE_FORMAT 21 } 22 } 23 24 func GetProtobufImageMime(buf []byte) (string, error) { 25 switch GetType(buf) { 26 case JPEG: 27 return "image/jpeg", nil 28 case PNG: 29 return "image/png", nil 30 case GIF: 31 return "image/gif", nil 32 case WEBP: 33 return "image/webp", nil 34 default: 35 return "", errors.New("mime type not found") 36 } 37 }