webp

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WebPConvertClient

type WebPConvertClient struct {
	Logger log.LeveledLogger
	// contains filtered or unexported fields
}

WebPConvertClient starts a webp conversion server and manages its lifecycle. Call Convert to convert an image.Image to a webp bytestream. This struct is only threadsafe after Start has been called.

func (*WebPConvertClient) Convert

func (c *WebPConvertClient) Convert(ctx context.Context, img image.Image, quality int, lossless, exact bool) ([]byte, error)

Convert encodes an image as TIFF and sends it to the conversion server. It returns either an error or the webp encoded bytes from the input image.

func (*WebPConvertClient) ConvertBytes added in v0.8.2

func (c *WebPConvertClient) ConvertBytes(ctx context.Context, img []byte, quality int, lossless, exact bool) ([]byte, error)

ConvertBytes takes an image in any format and sends it to the conversion server. It returns either an error or the webp encoded bytes from the input image.

func (*WebPConvertClient) ConvertBytesStreaming added in v0.9.0

func (c *WebPConvertClient) ConvertBytesStreaming(ctx context.Context, img []byte, quality int, lossless, exact bool) (io.ReadCloser, error)

ConvertBytesStreaming takes an image in any format and sends it to the conversion server. It returns either an error or the webp encoded bytes as a ReadCloser from the input image. The caller must Close the returned ReadCloser or it will leak.

func (*WebPConvertClient) Start

func (c *WebPConvertClient) Start(ctx context.Context) error

Start starts the server, cancelling the passed context will stop the server process. It is important to pass a real context into the process and not just context.Background. This function will return an error if setup fails but does not block.

Jump to

Keyboard shortcuts

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