image

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

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

Go to latest
Published: Jun 4, 2016 License: LGPL-3.0 Imports: 8 Imported by: 0

README

Build Status GoDoc Built with Spacemacs

golibri/image

Incremental image processing from web sources. Reads from png and jpg sources, but uses only jpeg internally and for exports.

installation

go get -u github.com/golibri/image

usage

  1. Initialize with an image URL (.png, .jpg or .jpeg)
  2. Download and analyze the actual image (bytes, height, width)
  3. Create a thumbnail of arbitrary size off the image (jpg)
  4. The Thumbnail also has a Base64 representation
img := image.New("https://golang.org/doc/gopher/frontpage.png"). // init
  Fetch(). // download and analyze
  CreateThumbnail(120, 70) // width, height

thumb := img.Thumbnail // thumb also has type "Image"

Check the struct's data fields for any info you might need. You can also create a Base64 off the original image if needed.

license

LGPLv3. (You can use it in commercial projects as you like, but improvements/bugfixes must flow back to this lib.)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Image

type Image struct {
	URL string

	Base64    string        // jpeg
	Binary    *bytes.Buffer // jpeg
	Height    int
	Width     int
	Thumbnail *Image
	// contains filtered or unexported fields
}

Image stands for an image object

func New

func New(URL string) *Image

New is a default constructor

func (*Image) CreateBase64

func (i *Image) CreateBase64() *Image

CreateBase64 creates and stores the Base64 string of the underlying image

func (*Image) CreateBinary

func (i *Image) CreateBinary() *Image

CreateBinary creates and stores the byte representation of the image

func (*Image) CreateThumbnail

func (i *Image) CreateThumbnail(width int, height int) *Image

CreateThumbnail shrinks the image to the specified sizes. Chainable.

func (*Image) Fetch

func (i *Image) Fetch() *Image

Fetch requests the stored URL and processes the binary data. Chainable.

func (*Image) URLIsImage

func (i *Image) URLIsImage() bool

URLIsImage checks whether the stored URL has png/jpg/jpeg suffix

Jump to

Keyboard shortcuts

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