process

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: 14 Imported by: 0

Documentation

Overview

package process provides a common interfaces for manipulating images before adding them to a picturebook.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvailableProcesses

func AvailableProcesses() []string

AvailableProcess returns the list of schemes that have been registered with `ProcessInitializeFunc` functions.

func RegisterProcess

func RegisterProcess(ctx context.Context, name string, fn ProcessInitializeFunc) error

RegisterProcess associates a URI scheme with a `ProcessInitializeFunc` initialization function.

Types

type ColourSpaceProcess added in v0.8.0

type ColourSpaceProcess struct {
	Process
	// contains filtered or unexported fields
}

type ColourSpaceProcess implements the `Process` interface to ensure that all the pixels in an image are mapped to a specific colour space.

func (*ColourSpaceProcess) Transform added in v0.8.0

func (f *ColourSpaceProcess) Transform(ctx context.Context, source_bucket *blob.Bucket, target_bucket *blob.Bucket, path string) (string, error)

Tranform maps all the pixels in the image located at 'path' in 'source_bucket' and writes the results to 'target_bucket' returning a new relative path on success.

type ContourProcess added in v0.8.0

type ContourProcess struct {
	Process
	// contains filtered or unexported fields
}

type ContourProcess implements the `Process` interface and transforms an image in to a series of black and white "contour" lines.

func (*ContourProcess) Transform added in v0.8.0

func (f *ContourProcess) Transform(ctx context.Context, source_bucket *blob.Bucket, target_bucket *blob.Bucket, path string) (string, error)

Tranform contours the image 'path' in 'source_bucket' and writes the results to 'target_bucket' returning a new relative path on success. If an image is not a JPEG file the method return an empty string.

type HalftoneProcess

type HalftoneProcess struct {
	Process
}

type HalftoneProcess implements the `Process` interface and applies a "halftone" dithering transformation to an image.

func (*HalftoneProcess) Transform

func (f *HalftoneProcess) Transform(ctx context.Context, source_bucket *blob.Bucket, target_bucket *blob.Bucket, path string) (string, error)

Tranform applies a "halftone" dithering tranformation to 'path' in 'source_bucket' and writes the results to 'target_bucket' returning a new relative path on success.

type MultiProcess

type MultiProcess struct {
	Process
	// contains filtered or unexported fields
}

type MultiProcess implements the `Process` interface and allows multiple `Process` instances to to tranform an image before adding it to a picturebook.

func (*MultiProcess) Transform

func (p *MultiProcess) Transform(ctx context.Context, source_bucket *blob.Bucket, target_bucket *blob.Bucket, path string) (string, error)

Tranform applies the `Tranform` method for all its internal `Process` instances. All processes must succeed in order for this method to succeed.

type NullProcess

type NullProcess struct {
	Process
}

type NullProcess implements the `Process` interface but does not apply any transformations to an image.

func (*NullProcess) Transform

func (f *NullProcess) Transform(ctx context.Context, source_bucket *blob.Bucket, target_bucket *blob.Bucket, path string) (string, error)

Tranform is a no-op, does not apply any tranformations to 'path' and returns an empty string.

type Process

type Process interface {
	// Transform reads a file from a `blob.Bucket` instance, processes it and writes the result to a
	// second `blob.Bucket` instance returning a new filename.
	Transform(context.Context, *blob.Bucket, *blob.Bucket, string) (string, error)
}

type Process provides a common interfaces for manipulating images before adding them to a picturebook.

func NewColourSpaceProcess added in v0.8.0

func NewColourSpaceProcess(ctx context.Context, uri string) (Process, error)

NewColourSpaceProcess returns a new instance of `ColourSpaceProcess` for 'uri' which is expected to take the form of:

colourspace://{PROFILE}
colorspace://{PROFILE}

Where {PROFILE} is one of the following: * `displayp3` which maps pixels to Apple's Display P3 colour space * `adobergb` which maps pixels to Adobe's RGB colour space

func NewContourProcess added in v0.8.0

func NewContourProcess(ctx context.Context, uri string) (Process, error)

NewContourProcess returns a new instance of `ContourProcess` for 'uri' which must be parsable as a valid `net/url` URL instance.

contour://?{PARAMETERS}

Where valid parameters are: * `iterations` The number of iterations to perform during the contour process. Default is 12. * `scale` The scale of the final contoured image. Default is 1.0.

func NewHalftoneProcess

func NewHalftoneProcess(ctx context.Context, uri string) (Process, error)

NewHalftoneProcess returns a new instance of `HalftoneProcess` for 'uri' which must be parsable as a valid `net/url` URL instance.

func NewMultiProcess

func NewMultiProcess(ctx context.Context, processes ...Process) (Process, error)

NewMultiProcess returns a new instance of `MultiProcess` for 'processes'

func NewNullProcess

func NewNullProcess(ctx context.Context, uri string) (Process, error)

NullProcess returns a new instance of `NullProcess` for 'uri' which must be parsable as a valid `net/url` URL instance.

func NewProcess

func NewProcess(ctx context.Context, uri string) (Process, error)

NewProcess returns a new `Process` instance for 'uri' whose scheme is expected to have been associated with an `ProcessInitializeFunc` (by the `RegisterProcess` method.

func NewRotateProcess

func NewRotateProcess(ctx context.Context, uri string) (Process, error)

NewRotateProcess returns a new instance of `RotateProcess` for 'uri' which must be parsable as a valid `net/url` URL instance.

type ProcessInitializeFunc

type ProcessInitializeFunc func(context.Context, string) (Process, error)

type ProcessInitializeFunc defined a common initialization function for instances implementing the Process interface. This is specified when the packages definining those instances call `RegisterProcess` and invoked with the `NewProcess` method is called.

type RotateProcess

type RotateProcess struct {
	Process
}

type RotateProcess implements the `Process` interface and rotates and image based on its EXIF `Orientation` property.

func (*RotateProcess) Transform

func (f *RotateProcess) Transform(ctx context.Context, source_bucket *blob.Bucket, target_bucket *blob.Bucket, path string) (string, error)

Tranform rotates the image 'path' in 'source_bucket' and writes the results to 'target_bucket' returning a new relative path on success. If an image is not a JPEG file the method return an empty string.

Jump to

Keyboard shortcuts

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