Go Binding for Imageflow
Quickly scale or modify images and optimize them for the web.
If the AGPLv3 does not work for you, you can get a commercial license on a sliding scale. If you have more than 1 server doing image processing your savings should cover the cost.
Docs are here
Imageflow dependents on libimageflow
for image processing capabilities. libimageflow
is available as the static and dynamic shared library on Linux and macOS. Currently libimageflow
is available as a dynamic library for Windows. Prebuilt shared libraries are available here. Add libimageflow
to OS path. Then it can be downloaded usinggo get
.
$ go get github.com/imazen/imageflow-go
A simple go program to create two image of different size.
package main;
import (
"io/ioutil"
imageflow "github.com/imazen/imageflow-go"
)
func main(){
step:=imageflow.NewStep()
data,_:=step
.Decode(imageflow.NewURL("https://jpeg.org/images/jpeg2000-home.jpg"))
.Branch(func(step *imageflow.Steps){
step
.ConstrainWithin(200,200)
.Encode(imageflow.NewFile("test_1.jpg"),imageflow.MozJPEG{})
}).ConstrainWithin(400,400)
.Encode(imageflow.GetBuffer("test"),imageflow.MozJPEG{})
.Execute()
ioutil.WriteFile("test_2.jpeg",data["test"],0644)
}