Documentation ¶
Overview ¶
package caption provides a common interface for different mechanisms to derive captions for images.
Index ¶
- func AvailableCaptions() []string
- func RegisterCaption(ctx context.Context, name string, fn CaptionInitializeFunc) error
- type Caption
- func NewCaption(ctx context.Context, uri string) (Caption, error)
- func NewExifCaption(ctx context.Context, uri string) (Caption, error)
- func NewFilenameCaption(ctx context.Context, uri string) (Caption, error)
- func NewJsonCaption(ctx context.Context, uri string) (Caption, error)
- func NewModtimeCaption(ctx context.Context, uri string) (Caption, error)
- func NewMultiCaption(ctx context.Context, uri string) (Caption, error)
- func NewMultiCaptionWithOptions(ctx context.Context, opts *MultiCaptionOptions) (Caption, error)
- func NewNoneCaption(ctx context.Context, uri string) (Caption, error)
- type CaptionInitializeFunc
- type ExifCaption
- type FilenameCaption
- type JsonCaption
- type ModtimeCaption
- type MultiCaption
- type MultiCaptionOptions
- type NoneCaption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AvailableCaptions ¶
func AvailableCaptions() []string
AvailableCaption returns the list of schemes that have been registered with `CaptionInitializeFunc` functions.
func RegisterCaption ¶
func RegisterCaption(ctx context.Context, name string, fn CaptionInitializeFunc) error
RegisterCaption associates a URI scheme with a `CaptionInitializeFunc` initialization function.
Types ¶
type Caption ¶
type Caption interface { // Text produces a caption derived from a file contained in a gocloud.dev/blob Bucket instance. Text(context.Context, *blob.Bucket, string) (string, error) }
type Caption provides a common interface for different mechanisms to derive captions for images.
func NewCaption ¶
NewCaption returns a new `Caption` instance for 'uri' whose scheme is expected to have been associated with an `CaptionInitializeFunc` (by the `RegisterCaption` method.
func NewExifCaption ¶ added in v0.4.6
NewExifCaption return a new instance of `ExifCaption` for 'uri'
func NewFilenameCaption ¶
NewExifCaption return a new instance of `FilenameCaption` for 'url'
func NewJsonCaption ¶ added in v0.7.0
NewJsonCaption return a new instance of `JsonCaption` for 'url'
func NewModtimeCaption ¶ added in v0.8.0
NewExifCaption return a new instance of `ModtimeCaption` for 'url' which is expected to take the form of:
modtime://
func NewMultiCaption ¶ added in v0.8.0
NewExifCaption return a new instance of `MultiCaption` for 'url'
func NewMultiCaptionWithOptions ¶ added in v0.8.0
func NewMultiCaptionWithOptions(ctx context.Context, opts *MultiCaptionOptions) (Caption, error)
type CaptionInitializeFunc ¶
type CaptionInitializeFunc defined a common initialization function for instances implementing the Caption interface. This is specified when the packages definining those instances call `RegisterCaption` and invoked with the `NewCaption` method is called.
type ExifCaption ¶ added in v0.4.6
type ExifCaption struct { Caption // contains filtered or unexported fields }
type ExifCaption implements the `Caption` interface and derives caption text from EXIF properties.
type FilenameCaption ¶
type FilenameCaption struct { Caption // contains filtered or unexported fields }
type FilenameCaption implements the `Caption` interface and derives caption text from image filenames.
type JsonCaption ¶ added in v0.7.0
type JsonCaption struct { Caption // contains filtered or unexported fields }
type JsonCaption implements the `Caption` interface and returns empty caption strings.
type ModtimeCaption ¶ added in v0.8.0
type ModtimeCaption struct { Caption // contains filtered or unexported fields }
type ModtimeCaption implements the `Caption` interface and derives caption text from image modification times.
type MultiCaption ¶ added in v0.8.0
type MultiCaption struct { Caption // contains filtered or unexported fields }
type MultiCaption implements the `Caption` interface and derives caption text from image multis.
type MultiCaptionOptions ¶ added in v0.8.0
type NoneCaption ¶
type NoneCaption struct {
Caption
}
type ExifCaption implements the `Caption` interface and returns empty caption strings.