|
@@ -1553,7 +1553,6 @@ type MediaMessage interface {
|
|
type MediaMessageWithThumbnail interface {
|
|
type MediaMessageWithThumbnail interface {
|
|
MediaMessage
|
|
MediaMessage
|
|
GetJpegThumbnail() []byte
|
|
GetJpegThumbnail() []byte
|
|
- GetCaption() string
|
|
|
|
}
|
|
}
|
|
|
|
|
|
type MediaMessageWithCaption interface {
|
|
type MediaMessageWithCaption interface {
|
|
@@ -1561,6 +1560,12 @@ type MediaMessageWithCaption interface {
|
|
GetCaption() string
|
|
GetCaption() string
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+type MediaMessageWithDimensions interface {
|
|
|
|
+ MediaMessage
|
|
|
|
+ GetHeight() uint32
|
|
|
|
+ GetWidth() uint32
|
|
|
|
+}
|
|
|
|
+
|
|
type MediaMessageWithFileName interface {
|
|
type MediaMessageWithFileName interface {
|
|
MediaMessage
|
|
MediaMessage
|
|
GetFileName() string
|
|
GetFileName() string
|
|
@@ -1602,7 +1607,12 @@ func (portal *Portal) convertMediaMessage(intent *appservice.IntentAPI, source *
|
|
}
|
|
}
|
|
|
|
|
|
var width, height int
|
|
var width, height int
|
|
- if strings.HasPrefix(msg.GetMimetype(), "image/") {
|
|
|
|
|
|
+ messageWithDimensions, ok := msg.(MediaMessageWithDimensions)
|
|
|
|
+ if ok {
|
|
|
|
+ width = int(messageWithDimensions.GetWidth())
|
|
|
|
+ height = int(messageWithDimensions.GetHeight())
|
|
|
|
+ }
|
|
|
|
+ if width == 0 && height == 0 && strings.HasPrefix(msg.GetMimetype(), "image/") {
|
|
cfg, _, _ := image.DecodeConfig(bytes.NewReader(data))
|
|
cfg, _, _ := image.DecodeConfig(bytes.NewReader(data))
|
|
width, height = cfg.Width, cfg.Height
|
|
width, height = cfg.Width, cfg.Height
|
|
}
|
|
}
|