emboss

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: BSD-3-Clause Imports: 20 Imported by: 0

README

go-image-emboss

Go package for interacting with the sfomuseum/swift-image-emboss-grpc tools

Documentation

Documentation is incomplete.

Example

import (
       "context"
       
       "github.com/sfomuseum/go-image-emboss"
)

ctx := context.Background()
embosser, _ := emboss.NewEmbosser(ctx, "grpc://localhost:1234")

combined := false

rsp, _ := embosser.EmbossImage(ctx, "example.jpg", combined)

for _, im := range rsp {
	// Do something with im (which is an `image.Image` instance here)
}		

Tools

$> make cli
go build -mod vendor -ldflags="-s -w" -o bin/emboss cmd/emboss/main.go
images-emboss
$> ./bin/emboss -h
Usage of ./bin/emboss:
  -combined
    	Return a single image combining all the subjects that were derived from an image.
  -embosser-uri string
    	A valid sfomuseum/go-image-emboss.Embosser URI. (default "grpc://localhost:1234")
Examples

Note that all these examples assume there is a copy of the sfomuseum/swift-image-emboss-grpc server instance already running somewhere it can be reached (localhost:1234 in these examples).

Single object

Given this image of a tie tack from Civil Air Transport (CAT) airlines passed to the gRPC image embossing service like this:

$> ./bin/emboss -embosser-uri grpc://localhost:1234 fixtures/cat-pin.jpg 
2023/10/02 12:13:39 fixtures/cat-pin-emboss-001.png

The image embossing service will return this image:

Multiple objects

Given this image of an Air France amenity kit passed to the gRPC image embossing service like this:

$> ./bin/emboss -embosser-uri grpc://localhost:1234 fixtures/af-kit.jpg 
2023/10/02 12:17:51 fixtures/af-kit-emboss-001.png
2023/10/02 12:17:51 fixtures/af-kit-emboss-002.png
2023/10/02 12:17:51 fixtures/af-kit-emboss-003.png
2023/10/02 12:17:51 fixtures/af-kit-emboss-004.png
2023/10/02 12:17:51 fixtures/af-kit-emboss-005.png

The image embossing service will return the following images:

Multiple objects combined

If you want the service to return all those images in a single image passed the -combined flag, like this:

$> ./bin/emboss -embosser-uri grpc://localhost:1234 -combined fixtures/af-kit.jpg
2023/10/02 12:28:57 fixtures/af-kit-emboss-combined-001.png

The image embossing service will return the following image:

See also

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterEmbosser

func RegisterEmbosser(ctx context.Context, scheme string, init_func EmbosserInitializationFunc) error

RegisterEmbosser registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `Embosser` instances by the `NewEmbosser` method.

func Schemes

func Schemes() []string

Schemes returns the list of schemes that have been registered.

Types

type Embosser

type Embosser interface {
	EmbossImage(context.Context, string, bool) ([]image.Image, error)
	EmbossImageWithReader(context.Context, io.Reader, string, bool) ([]image.Image, error)
	Close(context.Context) error
}

func NewEmbosser

func NewEmbosser(ctx context.Context, uri string) (Embosser, error)

NewEmbosser returns a new `Embosser` instance configured by 'uri'. The value of 'uri' is parsed as a `url.URL` and its scheme is used as the key for a corresponding `EmbosserInitializationFunc` function used to instantiate the new `Embosser`. It is assumed that the scheme (and initialization function) have been registered by the `RegisterEmbosser` method.

func NewGrpcEmbosser

func NewGrpcEmbosser(ctx context.Context, uri string) (Embosser, error)

func NewNullEmbosser

func NewNullEmbosser(ctx context.Context, uri string) (Embosser, error)

type EmbosserInitializationFunc

type EmbosserInitializationFunc func(ctx context.Context, uri string) (Embosser, error)

EmbosserInitializationFunc is a function defined by individual embosser package and used to create an instance of that embosser

type GrpcEmbosser

type GrpcEmbosser struct {
	// contains filtered or unexported fields
}

func (*GrpcEmbosser) Close

func (e *GrpcEmbosser) Close(ctx context.Context) error

func (*GrpcEmbosser) EmbossImage

func (e *GrpcEmbosser) EmbossImage(ctx context.Context, path string, combined bool) ([]image.Image, error)

func (*GrpcEmbosser) EmbossImageWithReader

func (e *GrpcEmbosser) EmbossImageWithReader(ctx context.Context, im_r io.Reader, path string, combined bool) ([]image.Image, error)

type NullEmbosser

type NullEmbosser struct {
}

func (*NullEmbosser) Close

func (e *NullEmbosser) Close(ctx context.Context) error

func (*NullEmbosser) EmbossImage

func (e *NullEmbosser) EmbossImage(ctx context.Context, path string, combined bool) ([]image.Image, error)

func (*NullEmbosser) EmbossImageWithReader

func (e *NullEmbosser) EmbossImageWithReader(ctx context.Context, r io.Reader, path string, combined bool) ([]image.Image, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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