Skip to content

Instantly share code, notes, and snippets.

@h2non
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h2non/7a8d1da29fafc59ccb05 to your computer and use it in GitHub Desktop.
Save h2non/7a8d1da29fafc59ccb05 to your computer and use it in GitHub Desktop.
Gist for issue: https://github.com/h2non/bimg/issues/44. Run: go run bimg-test.go
package main
import (
"fmt"
"gopkg.in/h2non/bimg.v0"
"os"
)
const operations = 10000
func main() {
buffer, err := bimg.Read("image.jpg")
if err != nil {
fmt.Fprintln(os.Stderr, err)
}
options := bimg.Options{
Width: 200,
Height: 200,
Crop: true,
Interpolator: bimg.BICUBIC,
Gravity: bimg.CENTRE,
Quality: 90,
}
options.Type = bimg.DetermineImageType(buffer)
for i := 0; i < operations; i += 1 {
_, err := bimg.NewImage(buffer).Process(options)
if err != nil {
fmt.Fprintln(os.Stderr, err)
break
}
fmt.Printf("Converting image: %d\n", i)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment