imgi

package module
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: MIT Imports: 10 Imported by: 0

README

imgi

Travis Build Status

imgi is an image procressing service.

Installation

You can install imgi from docker or build from source.

Build from source
Prerequisite
  • GO 1.14+
  • libvips 8.9+
Build and install
go get -u github.com/imgi/imgi/cmd/imgi

Usage

Docker

Start imgi container with default configuration:

docker run -d -p 6969:6969 -v /path/to/images:/images imgi/imgi
Example

Start imgi server with a custom configuration file:

imgi -c imgi.conf

Resize an image:

http://localhost:6969/images/image.jpg?imgi=resize:w_640,h_480,m_fit
API

API is access by providing an http query string imgi with the following format:

imgi=operation0:option0_value0,option1_value1|operation1:option0_value0

Operations

Resize resize
Option Type Value Description
m string fit, fill, flex default: fit content mode:
fit: aspect ratio preserved, width and height attain
fill: aspect ratio ignored, width and height attain
flex: aspect ratio preserved, width or height attain
w int [1, 10000] output image width
h int [1, 10000] output image height
Crop crop
Option Type Value Description
w int [1, width - x] output image width
h int [1, height - y] output image height
x int [0, width] x-axis along image width
y int [0, height] y-axis along image height

License

MIT - Copyright (c) 2020 Chen Guohui

Documentation

Index

Constants

View Source
const Version = "0.0.0"

Variables

View Source
var (
	ErrNotFound = errors.New("Not found")
)

Functions

This section is empty.

Types

type Action

type Action func(Image, Options) (Image, error)

func (Action) Act

func (a Action) Act(img Image, opts Options) (Image, error)

type Config

type Config struct {
	General   GeneralConfig
	Log       LogConfig
	Locations map[string]string
}

func LoadConfig

func LoadConfig(configFile string) (Config, error)

type GeneralConfig

type GeneralConfig struct {
	Port int
}

type Image

type Image struct {
	Buf  []byte
	Mime string
}

func Crop

func Crop(img Image, opts Options) (Image, error)

func Resize

func Resize(img Image, opts Options) (Image, error)

type LogConfig

type LogConfig struct {
	File  string
	Level string
}

type Mode

type Mode int
const (
	Fit  Mode = iota // aspect ratio preserved, width and height attain
	Fill             // aspect ratio ignored, width and height attain
	Flex             // aspect ratio preserved, width or height attain
)

type Operation

type Operation struct {
	Name    string
	Options Options
	Action  Action
}

type Options

type Options struct {
	Width  int
	Height int
	Mode   Mode
	X      int
	Y      int
}

type Server

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

func NewServer

func NewServer(config Config) *Server

func (*Server) Start

func (srv *Server) Start()

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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