lena

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

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

Go to latest
Published: Aug 18, 2014 License: MIT Imports: 8 Imported by: 2

README

go-lena

Get classic image processing example image, Lena.

lena.result.jpg

Installation

for production
go get github.com/koyachi/go-lena

Default bindata.go contains lena image as code, so the program that imports go-lena is easy to depoly. But compile and image reading time is slow.

for debug
go get github.com/koyachi/go-lena
cd $GOPATH/src/github.com/koyachi/go-lena
make bindata.go.debug

bindata.go for debug not contains lena image as go code, it reads tiff file from build environment's directory layout.

  • Pros: a fast compile and image reading time.
  • Cons: a failure to read lena image. ($GOPATH)

Example

package main

import (
	"github.com/koyachi/go-lena"
	"fmt"
	"image/jpeg"
	"log"
	"os"
	"path/filepath"
)

func main() {
	fmt.Printf("processing...\n")
	img, err := lena.Image()
	if err != nil {
		log.Fatal(err)
	}

	path, err := filepath.Abs("result.jpg")
	if err != nil {
		log.Fatal(err)
	}
	file, err := os.Create(path)
	if err != nil {
		log.Fatal(err)
	}
	err = jpeg.Encode(file, img, nil)
	if err != nil {
		log.Fatal(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func Image

func Image() (img image.Image, err error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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