imgurl

package module
v0.0.0-...-eac9b9e Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2015 License: BSD-3-Clause Imports: 13 Imported by: 1

README

imgurl

Package imgurl offers methods to fetch, thumbnail and convert remote images to a base64 encoded data URL.

#Usage

resp,_, err := Urlify("https://raw.githubusercontent.com/sebkl/globejs/master/screenshots/sample_plain.png",100,100)
fmt.Println(err,resp)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(source io.Reader, mt string, mwh ...int) (i image.Image, err error)

Decode reads the given image and scales it to the given size keeping the aspect ratio

func NudeFilter

func NudeFilter(img image.Image) (image.Image, interface{})

NudeFilter checks if the image may be a nude image and returns a boolean tag accordingly.

func Urlify

func Urlify(url string, maxwidth, maxheight int, filters ...Filter) (ret string, tags []interface{}, err error)

Urilfy fetches the image referenced by the given url, scales it to the given sizes keeping the aspect ratio and transcods it to a base64 encoded data url.

func UrlifyC

func UrlifyC(c *http.Client, url string, maxwidth, maxheight int, filters ...Filter) (ret string, tags []interface{}, err error)

UrilfyC fetches the image referenced by the given url, scales it to the given sizes keeping the aspect ratio and transcods it to a base64 encoded data url. Hereby the given http Client is used.

func UrlifyR

func UrlifyR(source io.Reader, mt string, maxwidth, maxheight int, filters ...Filter) (ret string, tags []interface{}, err error)

UrlifyR reads the image fromt he given reader, scales it to the given sizes keeping the apsect ratio and transcods it to a base74 encoded data url.

Types

type Filter

type Filter func(image.Image) (image.Image, interface{})

type Request

type Request struct {
	Url                 string
	Maxwidth, Maxheight int
	Payload             interface{}
	Filters             []Filter
}

type Response

type Response struct {
	Image   string
	Payload interface{}
	Tags    []interface{}
}

type TranscodeService

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

func NewTranscodeService

func NewTranscodeService(worker, buffersize int) (ret *TranscodeService)

NewTranscodeService creates worker routines that transcode images in parallel. The amount of worker routines is taken from parameters including the size of the input and output channel buffer.

func (*TranscodeService) Full

func (t *TranscodeService) Full() bool

func (*TranscodeService) Get

func (t *TranscodeService) Get() *Response

func (*TranscodeService) Push

func (t *TranscodeService) Push(r *Request)

func (*TranscodeService) Ready

func (t *TranscodeService) Ready() bool

Jump to

Keyboard shortcuts

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