status-go/images/type.go
Godfrain Jacques 5f6f7e502d
(fix/status-go) fix profile picture update/removal (#4570)
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`
2024-01-24 12:09:28 -08:00

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")
}
}