-
Notifications
You must be signed in to change notification settings - Fork 14
/
image.go
32 lines (26 loc) · 889 Bytes
/
image.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package asnormalizer
import (
"github.com/benpate/hannibal/streams"
"github.com/benpate/hannibal/vocab"
)
// Image normalizes an Image object
func Image(image streams.Image) map[string]any {
return map[string]any{
vocab.PropertyHref: first(image.Href(), image.URL()),
vocab.PropertyHeight: image.Height(),
vocab.PropertyWidth: image.Width(),
vocab.PropertyMediaType: image.MediaType(),
vocab.PropertySummary: image.Summary(),
}
}
// AttachmentAsImage normalizes an Image object
func AttachmentAsImage(attachment streams.Document) map[string]any {
attachment = biggestImage(attachment)
return map[string]any{
vocab.PropertyHref: attachment.URL(),
vocab.PropertyHeight: attachment.Height(),
vocab.PropertyWidth: attachment.Width(),
vocab.PropertyMediaType: attachment.MediaType(),
vocab.PropertySummary: attachment.Content(),
}
}