mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-15 02:15:54 -07:00
Adding basic smartcrop support.
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
This commit is contained in:
parent
24d84e6d8c
commit
9c914467b3
7 changed files with 58 additions and 3 deletions
|
|
@ -455,6 +455,23 @@ func TestFluentInterface(t *testing.T) {
|
|||
Write("fixtures/test_image_fluent_out.png", image.Image())
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
func initImage(file string) *Image {
|
||||
buf, _ := imageBuf(file)
|
||||
return NewImage(buf)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue