caption

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2024 License: BSD-3-Clause Imports: 12 Imported by: 2

Documentation

Overview

package caption provides a common interface for different mechanisms to derive captions for images.

Index

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

func NewCaption(ctx context.Context, uri string) (Caption, error)

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

func NewExifCaption(ctx context.Context, uri string) (Caption, error)

NewExifCaption return a new instance of `ExifCaption` for 'uri'

func NewFilenameCaption

func NewFilenameCaption(ctx context.Context, uri string) (Caption, error)

NewExifCaption return a new instance of `FilenameCaption` for 'url'

func NewJsonCaption added in v0.7.0

func NewJsonCaption(ctx context.Context, uri string) (Caption, error)

NewJsonCaption return a new instance of `JsonCaption` for 'url'

func NewModtimeCaption added in v0.8.0

func NewModtimeCaption(ctx context.Context, uri string) (Caption, error)

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

func NewMultiCaption(ctx context.Context, uri string) (Caption, error)

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)

func NewNoneCaption

func NewNoneCaption(ctx context.Context, uri string) (Caption, error)

NewNoneCaption return a new instance of `NoneCaption` for 'url'

type CaptionInitializeFunc

type CaptionInitializeFunc func(context.Context, string) (Caption, error)

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.

func (*ExifCaption) Text added in v0.4.6

func (c *ExifCaption) Text(ctx context.Context, bucket *blob.Bucket, path string) (string, error)

Text returns a caption string derived from EXIF data in 'path'

type FilenameCaption

type FilenameCaption struct {
	Caption
	// contains filtered or unexported fields
}

type FilenameCaption implements the `Caption` interface and derives caption text from image filenames.

func (*FilenameCaption) Text

func (c *FilenameCaption) Text(ctx context.Context, bucket *blob.Bucket, path string) (string, error)

Text returns a caption string derived from the base name of 'path'

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.

func (*JsonCaption) Text added in v0.7.0

func (c *JsonCaption) Text(ctx context.Context, bucket *blob.Bucket, path string) (string, error)

Text returns an empty caption string

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.

func (*ModtimeCaption) Text added in v0.8.0

func (c *ModtimeCaption) Text(ctx context.Context, bucket *blob.Bucket, path string) (string, error)

Text returns a caption string derived from the modification time of 'path'

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.

func (*MultiCaption) Text added in v0.8.0

func (c *MultiCaption) Text(ctx context.Context, bucket *blob.Bucket, path string) (string, error)

Text returns a caption string derived from the base name of 'path'

type MultiCaptionOptions added in v0.8.0

type MultiCaptionOptions struct {
	Captions   []Caption
	Combined   bool
	AllowEmpty bool
}

type NoneCaption

type NoneCaption struct {
	Caption
}

type ExifCaption implements the `Caption` interface and returns empty caption strings.

func (*NoneCaption) Text

func (c *NoneCaption) Text(ctx context.Context, bucket *blob.Bucket, path string) (string, error)

Text returns an empty caption string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL