@@ -81,7 +81,8 @@ type NamedImage struct {
8181 mimeType string
8282}
8383
84- func NamedImageFromBytes (data []byte , sourceName string , mimeType string ) (NamedImage , error ) {
84+ // NamedImageFromBytes constructs a NamedImage from a byte slice, source name, and mime type.
85+ func NamedImageFromBytes (data []byte , sourceName , mimeType string ) (NamedImage , error ) {
8586 if data == nil {
8687 return NamedImage {}, fmt .Errorf ("must provide image bytes to construct a named image from bytes" )
8788 }
@@ -91,7 +92,8 @@ func NamedImageFromBytes(data []byte, sourceName string, mimeType string) (Named
9192 return NamedImage {data : data , SourceName : sourceName , mimeType : mimeType }, nil
9293}
9394
94- func NamedImageFromImage (img image.Image , sourceName string , mimeType string ) (NamedImage , error ) {
95+ // NamedImageFromImage constructs a NamedImage from an image.Image, source name, and mime type.
96+ func NamedImageFromImage (img image.Image , sourceName , mimeType string ) (NamedImage , error ) {
9597 if img == nil {
9698 return NamedImage {}, fmt .Errorf ("must provide image to construct a named image" )
9799 }
@@ -101,6 +103,7 @@ func NamedImageFromImage(img image.Image, sourceName string, mimeType string) (N
101103 return NamedImage {img : img , SourceName : sourceName , mimeType : mimeType }, nil
102104}
103105
106+ // Image returns the image.Image of the NamedImage.
104107func (ni * NamedImage ) Image (ctx context.Context ) (image.Image , error ) {
105108 if ni .img == nil {
106109 if ni .data == nil {
@@ -115,6 +118,7 @@ func (ni *NamedImage) Image(ctx context.Context) (image.Image, error) {
115118 return ni .img , nil
116119}
117120
121+ // Bytes returns the byte slice of the NamedImage.
118122func (ni * NamedImage ) Bytes (ctx context.Context ) ([]byte , error ) {
119123 if ni .data == nil {
120124 if ni .img == nil {
0 commit comments