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.
What is GIFT?
For developers building applications in Go that require robust image processing and manipulation, the GIFT (Go Image Processing Toolkit) library stands out as a premier, fully packaged solution. This open-source toolkit is entirely self-contained, requiring no external plugins or dependencies outside the Go ecosystem, and can be downloaded directly from Git for seamless integration. By incorporating GIFT into your software application, you instantly gain access to a comprehensive suite of image processing features. These essential functions include resizing images, cropping with precision, applying artistic filters, and adjusting saturation levels to enhance visual appeal, all through an intuitive and lightweight interface.
What makes GIFT an exceptional choice is its flexibility and developer-friendly design. Beyond utilizing the extensive collection of pre-built filters within the toolkit, developers have the creative freedom to design and implement entirely new filters or generate new images from scratch. Its architecture eliminates the need for complex cross-platform compatibility tweaks, ensuring consistent performance and ease of use. As a pure Go library, it is the perfect open-source tool for developers who are comfortable using Go, offering a powerful yet straightforward approach to integrating advanced image processing capabilities directly into their projects without unnecessary overhead.
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/giftApply 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()))
g.Draw(dst, src)
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.
How to 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.
gift.New().Draw(dstImage, bgImage)
// Draw the fgImage over the dstImage at the (100, 100) position.
gift.New().DrawAt(dstImage, fgImage, image.Pt(100, 100), gift.OverOperator)