tinify

package module
v0.0.0-...-7fc9c21 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2020 License: MIT Imports: 9 Imported by: 1

README

Tinify API client for Golang

This is a fork of https://github.com/gwpp/tinify-go with custom fixes

Fixes

  • Small code improvements
  • Fix resize option scale

License

This software is licensed under the MIT License. View the license.

Documentation

Index

Constants

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

Variables

This section is empty.

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

Jump to

Keyboard shortcuts

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