tinify – codeberg.org/jlelse/tinify Index | Files

package tinify

import "codeberg.org/jlelse/tinify"

Index

Constants

const (
	ResizeMethodScale = "scale"
	ResizeMethodFit   = "fit"
	ResizeMethodCover = "cover"
)
const ApiEndpoint = "https://api.tinify.com"

Functions

func SetKey

func SetKey(setKey string)

Types

type Client

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

func GetClient

func GetClient() *Client

func NewClient

func NewClient(key string) (c *Client, err error)

func (*Client) Request

func (c *Client) Request(method string, url string, body interface{}) (response *http.Response, err error)

type ResizeMethod

type ResizeMethod string

type ResizeOption

type ResizeOption struct {
	Method ResizeMethod `json:"method"`
	Width  int64        `json:"width,omitempty"`
	Height int64        `json:"height,omitempty"`
}

type Result

type Result struct {
	*ResultMeta
	// contains filtered or unexported fields
}

func NewResult

func NewResult(meta http.Header, data []byte) *Result

func (*Result) ContentType

func (r *Result) ContentType() string

func (*Result) Data

func (r *Result) Data() []byte

func (*Result) MediaType

func (r *Result) MediaType() string

func (*Result) Size

func (r *Result) Size() int64

func (*Result) ToBuffer

func (r *Result) ToBuffer() []byte

func (*Result) ToFile

func (r *Result) ToFile(path string) error

type ResultMeta

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

func NewResultMeta

func NewResultMeta(meta http.Header) *ResultMeta

type Source

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

func FromBuffer

func FromBuffer(buf []byte) (s *Source, err error)

func FromFile

func FromFile(path string) (s *Source, err error)

func FromUrl

func FromUrl(url string) (s *Source, err error)

func (*Source) Resize

func (s *Source) Resize(option *ResizeOption) error

func (*Source) ToFile

func (s *Source) ToFile(path string) error

Source Files

client.go result.go result_meta.go source.go tinify.go

Version
v0.0.0-20200123222407-7fc9c21822b0 (latest)
Published
Jan 23, 2020
Platform
linux/amd64
Imports
9 packages
Last checked
2 months ago

Tools for package owners.