Open Source Image Manipulation Library for Go Developers
GIFT is one of the easiest, open source library to use when it comes to image processing and manipulations while using Go.
When it comes to developing applications in Go that rely on image processing and manipulation, GIFT (Go Image Processing Toolkit) library is one of the best, fully packaged library that you can use. It requires no extra plugins or libraries that are outside of the scope of Go, and can be downloaded directly from Git.
As an open source library, you can easily include GIFT to your software application to allow image processing features like resizing image, cropping, adding filters, increasing or decreasing saturation and much more.
Similarly, you can also create a new filter or new image, apart from using the already added filters in the toolkit. It is pretty easy to use, lightweight and doesn’t require cross platform compatibility or tweaks. It is the perfect Open Source library for developers comfortable using Go.
At A Glance
An overview of GIFT features.
GIFT supports popular Image file formats listed below.
GIFT can be used in multiple environments like Node or browsers etc.
- Go 1.2+
Getting Started with GIFT
The easiest and recommend way to install GIFT is via GitHub. Please use the following command for an easy and smooth installation..
Install GIFT via GitHub
go get -u github.com/disintegration/gift
Apply Filters using Free Go Library
The open source GIFT library enables software developers to programmatically apply filters in images. With the help of the Draw function you can apply all the filters and changes to the source (src) image, and provides you the output in the result of a destination (dst) image. The changes start from the top left corner and go on so forth.
How to Apply ColorBalance Filter via Go API
g := gift.New(
gift.ColorBalance(20, -20, 0), // +20% red, -20% green
dst := image.NewRGBA(g.Bounds(src.Bounds()))
Free Go Library to Change Image Composition
When it comes to changing the composition of an image there are two function that support it, first being CopyOperator. With CopyOperator you can replace the pixels of your dst image with the pixels of the filtered src image. This change can be applied with the help of the Draw function mentioned above.
Apply Image Composition via DrawAt Filter via Go
// It outputs the filtered src image to the dst image
g.DrawAt(dst, src, dst.Bounds().Min, gift.CopyOperator)
Using Over Operator in Go GIFT Library
In case you want to superpose one image over the other, the OverOperator function can get the job done. This mode can be useful in case you want to place transparent areas of a src image on top of the dst image.
How to Create Copy of Image via Go Library
// Create a new image with dimensions of the bgImage.
dstImage := image.NewRGBA(bgImage.Bounds())
// Copy the bgImage to the dstImage.
// Draw the fgImage over the dstImage at the (100, 100) position.
gift.New().DrawAt(dstImage, fgImage, image.Pt(100, 100), gift.OverOperator)