mirror of
https://github.com/status-im/status-go.git
synced 2025-01-10 14:47:06 +00:00
5f6f7e502d
This PR fixes [9947](status-im/status-desktop#9947) and contains : - Commit to fix the changing of custom picture and having the change reflected on contact's side - Commit to fix the deleting of picture and having the change reflected on contact's side - Rename confusing `ImageType` to `ImageFormat`
38 lines
721 B
Go
38 lines
721 B
Go
package images
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/status-im/status-go/protocol/protobuf"
|
|
)
|
|
|
|
func GetProtobufImageFormat(buf []byte) protobuf.ImageFormat {
|
|
switch GetType(buf) {
|
|
case JPEG:
|
|
return protobuf.ImageFormat_JPEG
|
|
case PNG:
|
|
return protobuf.ImageFormat_PNG
|
|
case GIF:
|
|
return protobuf.ImageFormat_GIF
|
|
case WEBP:
|
|
return protobuf.ImageFormat_WEBP
|
|
default:
|
|
return protobuf.ImageFormat_UNKNOWN_IMAGE_FORMAT
|
|
}
|
|
}
|
|
|
|
func GetProtobufImageMime(buf []byte) (string, error) {
|
|
switch GetType(buf) {
|
|
case JPEG:
|
|
return "image/jpeg", nil
|
|
case PNG:
|
|
return "image/png", nil
|
|
case GIF:
|
|
return "image/gif", nil
|
|
case WEBP:
|
|
return "image/webp", nil
|
|
default:
|
|
return "", errors.New("mime type not found")
|
|
}
|
|
}
|