govips

module
v0.0.0-...-b1b72c7 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2020 License: MIT

README

govips GoDoc Go Report Card GitHub release (latest SemVer) License Build Status Coverage Status

A fast image processing library for Go

This package wraps the core functionality of libvips image processing library by exposing all image operations on first-class types in Go.

Libvips is generally 4-8x faster than other graphics processors such as GraphicsMagick and ImageMagick. Check the benchmark: Speed and Memory Use

The intent for this is to enable developers to build extremely fast image processors in Go, which is suited well for concurrent requests.

Requirements

  • libvips 8.10+
  • C compatible compiler such as gcc 4.6+ or clang 3.0+
  • Go 1.14+

Installation

go get -u github.com/davidbyttow/govips/v2
Dependencies on macOS

Use homebrew to install vips and pkg-config

brew install vips pkg-config
Dependencies on Ubuntu

You need at least libvips 8.10.2 to work with govips. Groovy (20.10) repositories have the latest version. However on Bionic (18.04) and Focal (20.04), you need to install libvips and dependencies from a backports repository:

sudo add-apt-repository ppa:tonimelisma/ppa

Then:

sudo apt -y install libvips-dev

Example usage

package main

import (
	"fmt"
	"io/ioutil"
	"os"

	"github.com/davidbyttow/govips/v2"
)

func checkError(err error) {
	if err != nil {
		fmt.Println("error:", err)
		os.Exit(1)
	}
}

func main() {
	vips.Startup(nil)

	image1, err := vips.NewImageFromFile("input.jpg")
	checkError(err)
	defer image1.Close()

	// Rotate the picture upright and reset EXIF orientation tag
	err = image1.AutoRotate()
	checkError(err)

	image1bytes, _, err := image1.Export(&vips.ExportParams{Format: vips.ImageTypeJPEG})
	err = ioutil.WriteFile("output.jpg", image1bytes, 0644)
	checkError(err)

	vips.Shutdown()
}

Contributing

In short, feel free to file issues or send along pull requests. See this guide on contributing for more information.

Credits

Thank you to John Cupitt for maintaining libvips and providing feedback on vips.

License

MIT - David Byttow

Directories

Path Synopsis
Package vips provides go bindings for libvips, a fast image processing library.
Package vips provides go bindings for libvips, a fast image processing library.

Jump to

Keyboard shortcuts

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