GithubHelp home page GithubHelp logo

kinu's Introduction

Kinu

Kinu is the server that resizing images. Inspired by cookpad's image server Tofu.

Status

It's development now for first alpha release.

Dependency

  • ImageMagick >= 6.8.9-9 && < 7.0.0

Installation

# Please to Install the ImageMagick before this
go get github.com/tokubai/kinu

or

docker pull tokubai/kinu:1.0.0.alpha13

Startup

go get

$ export KINU_LOG_LEVEL=info
$ export KINU_RESIZE_ENGINE=ImageMagick
$ export KINU_STORAGE_TYPE=File 
$ export KINU_FILE_DIRECTORY=/tmp/kinu
$ kinu
INFO[0000] setup resize engine                           resize_engine_type=ImageMagick
INFO[0000] setup storage                                 storage_type=File
INFO[0000] [starting kinu on 127.0.0.1:8080]
$ curl http://localhost:8080/version

docker run

$ docker run tokubai/kinu:1.0.0.alpha13
INFO[0000] setup resize engine                           resize_engine_type=ImageMagick
INFO[0000] setup storage                                 storage_type=File
INFO[0000] [starting kinu on 0.0.0.0:80]
$ curl http://localhost/version

Usage

ImageUpload

kinu.gem(Recommended)

require 'kinu'
Kinu::Resource.new(:foods, 1).upload(open('/path/to/image.jpg'))

curl

$ curl -X POST -F id=1 -F name=foods -F image=@/path/to/image http://localhost/upload

GetResizedImage

kinu.gem(Recommended)

require 'kinu'
require 'open-uri'
uri = Kinu::Resource.new(:foods, 1).uri(width: 280, height: 300) #<URI::HTTP http://localhost/images/foods/w=280,h=300/1.jpg>
open(uri).read

curl

$ curl http://localhost/images/foods/w=280,h=300/1.jpg

UploadToSandbox(Temporary)

kinu.gem(Recommended)

require 'kinu'
Kinu::Sandbox.upload(open('/path/to/image.jpg')) #<Kinu::Sandbox:0x007fdf92bdc490 @id="db4f1509-e2f5-40a7-9944-a6b0024f2a24", @name="__sandbox__">

curl

$ curl -X POST -F image=@/path/to/image http://localhost/sandbox

Attach from Sandbox

kinu.gem(Recommended)

require 'kinu'
Kinu::Sandbox.upload(open('/path/to/image.jpg')).attach_to(:foods, 1) #<Kinu::Resource:0x007fdf92b44a00 @id="1", @name="foods">

curl

$ curl -X POST -F sandbox_id=db4f1509-e2f5-40a7-9944-a6b0024f2a24 -F name=foods -F id=1 http://localhost/sandbox

Specification

Endpoints

now writing

Image resize query

now writing

Environment variables

name required default value valid value type note
KINU_BIND 127.0.0.1:80 IP:PORT / unix domain socket path / Einhorn(einhorn@[num]) / FileDescripter(fd@[num]) Compliance with the specifications of the goji/bind package.
KINU_DEBUG none true enable pprof
KINU_RESIZE_ENGINE none ImageMagick
KINU_LOG_LEVEL none panic / fatal / error / warning / info / debug
KINU_LOG_FORMAT text ltsv / json / text
KINU_RESIZE_WORKER_MODE none true
KINU_RESIZE_WORKER_MAX_SIZE cpu num * 10 Integer
KINU_RESIZE_WORKER_WAIT_BUFFER KINU_RESIZE_WORKER_SIZE * 3 Integer
KINU_STORAGE_TYPE none File / S3
KINU_FILE_DIRECTORY none directory path When the File has been set in a KINU_STORAGE_TYPE\ you must set this variable.
KINU_S3_REGION none AWS Region When the S3 has been set in a KINU_STORAGE_TYPE\ you must set this variable.
KINU_S3_BUCKET none Amazon S3 bucket When the S3 has been set in a KINU_STORAGE_TYPE\ you must set this variable.
KINU_S3_BUCKET_BASE_PATH none
AWS_ACCESS_KEY_ID none Compliance with the specifications of the aws-sdk-go package.
AWS_SECRET_ACCESS_KEY none Compliance with the specifications of the aws-sdk-go package.

Directory structure of the image storage.

now writing

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/tokubai/kinu

Thanks

Author

kinu's People

Contributors

takatoshi-maeda avatar fukajun avatar wata-gh avatar tomorrowkey avatar shuhei-kaneko avatar fisto avatar hogelog avatar

Stargazers

Takaaki Minowa avatar Yuya Ito avatar Ryo.Takahashi avatar mohemohe avatar supermomonga avatar Ryota Yoshikawa avatar Hidemi Yukita avatar  avatar milligramme avatar Shota Iguchi avatar Nam Nguyen avatar  avatar shikakun avatar Ryusuke Sekiguchi avatar  avatar Nguyen Van Nhu avatar Issei Naruta avatar Mizuki Asada avatar Toshihiro Yagi avatar Yoshiteru Negishi avatar

Watchers

Takashi OGURA avatar  avatar James Cloos avatar  avatar Youichi Otani avatar  avatar dfukagawa avatar

kinu's Issues

Change envvar behavior

  • KINU_RESIZE_ENGINE
    • set default ImageMagick
  • KINU_LOG_LEVEL
    • set default info
  • KINU_DEBUG
    • rename to KINU_ENABLE_PPROF

support circular cropping

In recent trends, user icons are often circular.
It seems to be flexible if it can be cropped on image server.

Support corner sticky cropping

We cannot set how to crop image for now.

c.f) Upper left corner sticky cropped thumbnails will provide better information for some sort of images (such as shop leaflets).

Upload Authentication

  • Can image uploading permitted clients only
  • Authontication delegate to storage providers
  • Local file storage if authentication skip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.