MCPcopy
hub / github.com/gopherdata/gophernotes / Image

Function Image

image.go:11–24  ·  view source on GitHub ↗

Image converts an image.Image to DisplayData containing PNG []byte, or to DisplayData containing error if the conversion fails

(img image.Image)

Source from the content-addressed store, hash-verified

9// Image converts an image.Image to DisplayData containing PNG []byte,
10// or to DisplayData containing error if the conversion fails
11func Image(img image.Image) Data {
12 bytes, mimeType, err := encodePng(img)
13 if err != nil {
14 return makeDataErr(err)
15 }
16 return Data{
17 Data: MIMEMap{
18 mimeType: bytes,
19 },
20 Metadata: MIMEMap{
21 mimeType: imageMetadata(img),
22 },
23 }
24}
25
26// encodePng converts an image.Image to PNG []byte
27func encodePng(img image.Image) (data []byte, mimeType string, err error) {

Callers

nothing calls this directly

Calls 3

encodePngFunction · 0.85
makeDataErrFunction · 0.85
imageMetadataFunction · 0.85

Tested by

no test coverage detected