• Stars
    star
    450
  • Rank 97,143 (Top 2 %)
  • Language
    Go
  • Created about 10 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Go Bindings for Vips (a super fast image processor)

Vips for go

This package is powered by the blazingly fast libvips image processing library, originally created in 1989 at Birkbeck College and currently maintained by JohnCupitt.

This is a loosely port of sharp an awesome module for node.js built by Lovell Fuller

The typical use case for this high speed package is to convert large images of many formats to smaller, web-friendly JPEG, PNG images of varying dimensions.

The performance of JPEG resizing is typically 8x faster than ImageMagick and GraphicsMagick, based mainly on the number of CPU cores available.

When generating JPEG output all metadata is removed and Huffman tables optimised without having to use separate command line tools like jpegoptim and jpegtran.

Installation

go get github.com/daddye/vips

libvips can take advantage of liborc if present.

Install libvips on Mac OS

brew install homebrew/science/vips --without-fftw --without-libexif --without-libgsf \
  --without-little-cms2 --without-orc --without-pango --without-pygobject3 \
  --without-gobject-introspection --without-python

Install libvips on Linux

Compiling from source is recommended:

sudo apt-get install automake build-essential git gobject-introspection \
  libglib2.0-dev libjpeg-turbo8-dev libpng12-dev gtk-doc-tools
git clone https://github.com/jcupitt/libvips.git
cd libvips
./bootstrap.sh
./configure --enable-debug=no --without-python --without-fftw --without-libexif \
  --without-libgf --without-little-cms --without-orc --without-pango --prefix=/usr
make
sudo make install
sudo ldconfig

Usage

You can use package from the command line (go install github.com/daddye/vips/vips-cmd):

vips-cmd -file test.jpg -width 400 -height 600 > /tmp/test.jpg

Or simply importing the package and then:

options := vips.Options{
	Width:        800,
	Height:       600,
	Crop:         false,
	Extend:       vips.EXTEND_WHITE,
	Interpolator: vips.BILINEAR,
	Gravity:      vips.CENTRE,
	Quality:      95,
}
f, _ := os.Open("/tmp/test.jpg")
inBuf, _ := ioutil.ReadAll(f)
buf, err := vips.Resize(inBuf, options)
if err != nil {
	fmt.Fprintln(os.Stderr, err)
	return
}
// do some with your resized image `buf`

Performance

Test by @lovell

Test environment

  • Intel Xeon L5520 2.27GHz 8MB cache
  • Ubuntu 13.10
  • libvips 7.38.5

The contenders

  • imagemagick-native - Supports Buffers only and blocks main V8 thread whilst processing.
  • imagemagick - Supports filesystem only and "has been unmaintained for a long time".
  • gm - Fully featured wrapper around GraphicsMagick.
  • sharp - Caching within libvips disabled to ensure a fair comparison.

The task

Decompress a 2725x2225 JPEG image, resize and crop to 720x480, then compress to JPEG.

Results

Module Input Output Ops/sec Speed-up
imagemagick-native buffer buffer 0.97 1
imagemagick file file 2.49 2.6
gm buffer file 3.72 3.8
gm buffer buffer 3.80 3.9
gm file file 3.67 3.8
gm file buffer 3.67 3.8
sharp buffer file 13.62 14.0
sharp buffer buffer 12.43 12.8
sharp file file 13.02 13.4
sharp file buffer 11.15 11.5
sharp +sharpen file buffer 10.26 10.6
sharp +progressive file buffer 9.44 9.7
sharp +sequentialRead file buffer 11.94 12.3

You can expect much greater performance with caching enabled (default) and using 16+ core machines.

Thanks

This module would never have been possible without the help and code contributions of the following people:

License

Copyright (C) 2014 Davide D'Agostino

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

foreverb

Small daemon framework for ruby, with logging, error handler, scheduling and much more.
Ruby
520
star
2

mini_record

ActiveRecord meets DataMapper, with MiniRecord you are be able to write schema inside your models.
Ruby
265
star
3

do

DO - IT! is a thin framework useful to manage remote servers through ssh.
Ruby
166
star
4

igo

Intermediate GoLang source representation
Go
142
star
5

leveldb

LevelDB for Ruby (embedded)
Ruby
126
star
6

lipsiadmin

Lipsiadmin is a new revolutionary admin for your projects. Lipsiadmin is based on Ext Js 3+. framework (with prototype adapter) and is ready for Rails 2.+. This admin is for newbie developper but also for experts, is not entirely written in javascript because the aim of developper wose build in a agile way web/site apps so we use extjs in a new intelligent way a mixin of β€œold” html and new ajax functions, for example ext manage the layout of page, grids, tree and errors, but form are in html code.
Ruby
105
star
7

trez

A fast image resizer
Go
102
star
8

githubwatcher

Github Growl Watcher, watch any project and get instant growl notifications for: updates, new watchers, forks and issues
Ruby
88
star
9

lightbox

LightBox Helper is a small but beautifull helper that automatize the process for include LightBox on our pages.
JavaScript
39
star
10

ruby_nsq

Ruby client for the NSQ realtime message processing system
Ruby
28
star
11

gruby

Go lang to Ruby transpiler
Go
26
star
12

soda.vim

Reinterpreted Soda Theme for Vim Users
Vim Script
21
star
13

lipsiablog

Lightweight, simple, fast, easy blogging engine written in rails and Lipsiadmin
JavaScript
17
star
14

exception-notifier

Exception Notifier Plugin for Rails, that send email notification and generate error pages that you can use with your controller Layout.
Ruby
13
star
15

google_tasks

This gem provides access to google tasks apis
Ruby
10
star
16

model

Naive sql to struct for go
Go
8
star
17

node.nim

Work in progress node pattern on the awesome Nimrod
Nim
7
star
18

goroutine

Simple goroutine model for Ruby.
Ruby
6
star
19

fiddler

Wrapper for Fiddler (Ruby 2.0 FFI impl)
Ruby
6
star
20

ruvy

FFI Bindings to Libuv (experimental)
Ruby
6
star
21

eva

Effortless event driven micro framework that runs on Ruby in a different syntax
Ruby
6
star
22

golia

WebSite Link and Speed Checker
Ruby
5
star
23

documents

Document nubble FS
Ruby
4
star
24

tomorrow.vim

Dark light version of new Tomorrow Theme
Vim Script
4
star
25

.vim

My vim editor, plugins, syntax and more.
Vim Script
3
star
26

forever

MOVED HERE: https://github.com/DAddYE/foreverb
3
star
27

wintersmith-perian

Browserify, Coffee, Stylus, UglifyJS and CleanCSS
CoffeeScript
3
star
28

gist

Repo as a gist
Nim
3
star
29

loop

A tiny Ruby program used to periodically execute a command.
Ruby
2
star
30

snippets

Snipmate custom snippets
2
star
31

.do

My Servo recipes
Ruby
1
star
32

yarv

RubyVM (yarv) compiler/decompiler, written in go.
Go
1
star
33

rosetta

One language to rule them all.
Ruby
1
star
34

homebrew-alt

My homebrews
Ruby
1
star
35

mrb

FFI bindings for mruby
Ruby
1
star
36

uv

Ruby bindings for libuv
Ruby
1
star
37

lipsiadmin-I18n

Repository for collecting Locale data for Lipsiadmin
1
star
38

igo.vim

Vim syntax for igo
Vim Script
1
star
39

coding-style

Coding style
1
star