feat: support multiple outputs

This commit is contained in:
Tomas Aparicio 2015-04-05 23:39:15 +02:00
parent d471c49348
commit ef10d7d7ec
9 changed files with 220 additions and 58 deletions

View file

@ -33,3 +33,31 @@ func TestResize(t *testing.T) {
t.Fatal("Cannot save the image")
}
}
func TestConvert(t *testing.T) {
options := Options{Width: 640, Height: 480, Crop: false, Type: PNG}
img, err := os.Open("fixtures/test.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)
}
if DetermineImageType(newImg) != PNG {
t.Fatal("Image is not png")
}
err = ioutil.WriteFile("result.png", newImg, 0644)
if err != nil {
t.Fatal("Cannot save the image")
}
}