nsqthumbnailer

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2015 License: Apache-2.0 Imports: 21 Imported by: 0

README

#nsqthumbnailer

nsq based consumer that generates thumbnails.

Nothing to see in there yet.

Dependencies

Before you import library, you need to install libjpeg-turbo.

On Ubuntu: sudo apt-get install libjpeg-turbo8-dev.

On Mac OS X: brew install libjpeg-turbo

How to use it

Start nsq machinery in 3 terminals

nsqlookupd 
nsqd --lookupd-tcp-address=127.0.0.1:4160
nsqadmin --lookupd-http-address=127.0.0.1:4161

How to debug

You can tail the messages flowing in the test topic

nsq_tail -lookupd-http-address=127.0.0.1:4161 -topic=test

Start nsq_thumbnailer

go install github.com/yml/nsqthumbnailer && nsqthumbnailer --topic=test --lookupd-http-address=127.0.0.1:4161 --concurrency=10

send messages

local file system

curl -d '{"srcImage": "file://tmp/nsqthumbnailer/src/image1.jpg, "opts": [{"rect":{"min":[200, 200], "max":[600,600]},"width":150, "height":0}, {"width":250, "height":0}, {"width":0, "height":350}], "dstFolder":""file://tmp/nsqthumbnailer/tumbs}' 'http://127.0.0.1:4151/put?topic=test'

S3

export AWS_SECRET_ACCESS_KEY=<secret>
export AWS_ACCESS_KEY_ID=<secret>

curl -d '{"srcImage": "s3://nsq-thumb-src-test/baignade.jpg", "opts": [{"rect":{"min":[200, 200], "max":[600,600]},"width":150, "height":0}, {"width":250, "height":0}, {"width":0, "height":350}], "dstFolder":"s3://nsq-thumb-dst-test/"}' 'http://127.0.0.1:4151/put?topic=test'

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(w io.Writer, img image.Image, format imaging.Format) error

Encode writes the image img to w in the specified format (JPEG, PNG, GIF, TIFF or BMP). copied from `imaging` and modified

Types

type ImageOpenSaver

type ImageOpenSaver interface {
	Open() (image.Image, error)
	Save(img image.Image) error
}

ImageOpenSaver interface that can Open and Close images from a given backend:fs, s3, ...

func NewImageOpenSaver

func NewImageOpenSaver(url *url.URL) (ImageOpenSaver, error)

NewImageOpenSaver return the relevant implementation of ImageOpenSaver based on the url.Scheme

type ThumbnailOpt

type ThumbnailOpt struct {
	DstImage string     `json:"dstImage,omitempty"`
	Rect     *rectangle `json:"rect,omitempty"`
	Width    int        `json:"width"`
	Height   int        `json:"height"`
}

type ThumbnailerMessage

type ThumbnailerMessage struct {
	SrcImage  string         `json:"srcImage"`
	DeleteSrc bool           `json:"deleteSrc",omitempty"`
	DstFolder string         `json:"dstFolder"`
	Opts      []ThumbnailOpt `json:"opts"`
}

func (*ThumbnailerMessage) DeleteImage

func (tm *ThumbnailerMessage) DeleteImage() error

func (*ThumbnailerMessage) GenerateThumbnails

func (tm *ThumbnailerMessage) GenerateThumbnails(errChan chan error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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