imagex

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHTTPDownloader = NewHTTPDownloader(http.Client{Timeout: time.Second * 3})
View Source
var ZeroImage = Image{}

Functions

func NewHTTPDownloader added in v0.1.3

func NewHTTPDownloader(client http.Client) *httpDownloader

Types

type Fetcher

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

func NewFetcher

func NewFetcher(
	downloader downloader,
) *Fetcher

func (Fetcher) Fetch added in v0.1.2

func (fetcher Fetcher) Fetch(ctx context.Context, rawURL string) (Image, error)

func (Fetcher) FetchBulk

func (fetcher Fetcher) FetchBulk(ctx context.Context, rawURLs []string) ([]Image, error)

type Image

type Image struct {
	Metadata Metadata
	Content  []byte
	// contains filtered or unexported fields
}

func Fetch added in v0.1.2

func Fetch(ctx context.Context, rawURL string) (Image, error)

func FetchBulk

func FetchBulk(ctx context.Context, rawURLs []string) ([]Image, error)

func Read

func Read(r io.Reader, path string) (Image, error)

func (*Image) Checksum

func (img *Image) Checksum() string

func (Image) IsZero

func (img Image) IsZero() bool

func (Image) Ratio

func (img Image) Ratio() float64

type Metadata

type Metadata struct {
	FileName string `json:"file_name"`
	Width    int    `json:"width"`
	Height   int    `json:"height"`
	Format   string `json:"format"`
	Mime     string `json:"mime"`
}

type S3Uploader added in v0.1.2

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

func NewS3Uploader

func NewS3Uploader(
	client *s3.Client,
	bucket string,
	path string,
) *S3Uploader

func (S3Uploader) Upload added in v0.1.2

func (u S3Uploader) Upload(ctx context.Context, image Image) (string, error)

type Uploader

type Uploader interface {
	Upload(ctx context.Context, image Image) (string, error)
}

Jump to

Keyboard shortcuts

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