feat(#1): initial implementation

This commit is contained in:
Tomas Aparicio 2015-03-29 22:55:04 +02:00
parent 8bcefc7736
commit 63f4b01c8d
14 changed files with 465 additions and 1 deletions

38
resize_test.go Normal file
View file

@ -0,0 +1,38 @@
package bimg
import (
"io/ioutil"
"net/http"
"os"
"testing"
)
func TestResize(t *testing.T) {
options := Options{Width: 800, Height: 600, Crop: false}
img, err := os.Open("fixtures/space.jpg")
if err != nil {
t.Fatal(err)
}
defer img.Close()
buf, err := ioutil.ReadAll(img)
if err != nil {
t.Fatal(err)
}
newImg, err := Resize(buf, options)
if err != nil {
t.Errorf("Resize(imgData, %#v) error: %#v", options, err)
}
debug("Image %s", http.DetectContentType(newImg))
if http.DetectContentType(newImg) != "image/jpeg" {
t.Fatal("Image is not jpeg")
}
err = ioutil.WriteFile("fixtures/test.jpg", newImg, 0644)
if err != nil {
t.Fatal("Cannot save the image")
}
}