mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-10 16:00:26 -07:00
parent
58b2be80a5
commit
cc2290cb45
8 changed files with 305 additions and 88 deletions
|
|
@ -45,6 +45,44 @@ func TestRotate(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func testColorspace(t *testing.T) {
|
||||
options := Options{Colorspace: true}
|
||||
buf, _ := Read("fixtures/sky.jpg")
|
||||
|
||||
newImg, err := Resize(buf, options)
|
||||
if err != nil {
|
||||
t.Errorf("Resize(imgData, %#v) error: %#v", options, err)
|
||||
}
|
||||
|
||||
if DetermineImageType(newImg) != JPEG {
|
||||
t.Fatal("Image is not jpeg")
|
||||
}
|
||||
|
||||
err = Write("fixtures/test_color_out.jpg", newImg)
|
||||
if err != nil {
|
||||
t.Fatal("Cannot save the image")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCorruptedImage(t *testing.T) {
|
||||
options := Options{Width: 800, Height: 600}
|
||||
buf, _ := Read("fixtures/corrupt.jpg")
|
||||
|
||||
newImg, err := Resize(buf, options)
|
||||
if err != nil {
|
||||
t.Errorf("Resize(imgData, %#v) error: %#v", options, err)
|
||||
}
|
||||
|
||||
if DetermineImageType(newImg) != JPEG {
|
||||
t.Fatal("Image is not jpeg")
|
||||
}
|
||||
|
||||
err = Write("fixtures/test_corrupt_out.jpg", newImg)
|
||||
if err != nil {
|
||||
t.Fatal("Cannot save the image")
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvalidRotate(t *testing.T) {
|
||||
options := Options{Width: 800, Height: 600, Rotate: 111}
|
||||
buf, _ := Read("fixtures/test.jpg")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue