-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Anshul Goyal
committed
May 17, 2020
1 parent
9b0ab02
commit 5e1828c
Showing
1 changed file
with
41 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,46 @@ | ||
# imageflow-go | ||
# Go Binding for [Imageflow](https://github.com/imazen/imageflow) | ||
|
||
![Windows](https://github.com/imazen/imageflow-go/workflows/Windows/badge.svg)![Macos](https://github.com/imazen/imageflow-go/workflows/Macos/badge.svg)![Linux](https://github.com/imazen/imageflow-go/workflows/Linux/badge.svg) | ||
|
||
# Usage Example | ||
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](https://pkg.go.dev/github.com/imazen/imageflow-go) | ||
|
||
# Installation | ||
|
||
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](https://github.com/imazen/imageflow/releases). Add `libimageflow`to OS path. Then it can be downloaded using`go get`. | ||
|
||
```bash | ||
$ go get github.com/imazen/imageflow-go | ||
``` | ||
|
||
# Usage | ||
|
||
A simple go program to create two image of different size. | ||
|
||
```go | ||
step := NewStep() | ||
step.Decode(&File{filename: "image.jpg"}).ConstrainWithinW(400).Branch(func(step *Steps) { | ||
step.ConstrainWithin(100, 100).Encode(&File{filename: "small.jpg"}, MozJPEG{}) | ||
}).Encode(&File{filename: "medium.jpg"}, MozJPEG{}).Execute() | ||
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) | ||
} | ||
|
||
``` | ||
``` |