Adding a test, verifying both ways of enabling SmartCrop work

This commit is contained in:
Mark van der Velden 2017-05-25 09:38:39 +02:00
parent 855de7ca55
commit 33bf9bdff6
4 changed files with 63 additions and 13 deletions

View file

@ -456,20 +456,23 @@ func TestFluentInterface(t *testing.T) {
}
func TestImageSmartCrop(t *testing.T) {
if VipsMajorVersion >= 8 && VipsMinorVersion > 4 {
i := initImage("northern_cardinal_bird.jpg")
buf, err := i.SmartCrop(300, 300)
if err != nil {
t.Errorf("Cannot process the image: %#v", err)
}
err = assertSize(buf, 300, 300)
if err != nil {
t.Error(err)
}
Write("fixtures/test_smart_crop.jpg", buf)
if !(VipsMajorVersion >= 8 && VipsMinorVersion > 4) {
t.Skipf("Skipping this test, libvips doesn't meet version requirement %s > 8.4", VipsVersion)
}
i := initImage("northern_cardinal_bird.jpg")
buf, err := i.SmartCrop(300, 300)
if err != nil {
t.Errorf("Cannot process the image: %#v", err)
}
err = assertSize(buf, 300, 300)
if err != nil {
t.Error(err)
}
Write("fixtures/test_smart_crop.jpg", buf)
}
func initImage(file string) *Image {