feat(#92): support Extend param with optional background

This commit is contained in:
Tomas Aparicio 2016-09-30 22:56:59 +01:00
parent 44636a88f0
commit 522cf71c73
6 changed files with 73 additions and 7 deletions

View file

@ -216,6 +216,40 @@ func TestNoColorProfile(t *testing.T) {
}
}
func TestEmbedExtendColor(t *testing.T) {
options := Options{Width: 400, Height: 600, Crop: false, Embed: true, Extend: ExtendWhite, Background: Color{255, 20, 10}}
buf, _ := Read("fixtures/test_issue.jpg")
newImg, err := Resize(buf, options)
if err != nil {
t.Errorf("Resize(imgData, %#v) error: %#v", options, err)
}
size, _ := Size(newImg)
if size.Height != options.Height || size.Width != options.Width {
t.Fatalf("Invalid image size: %dx%d", size.Width, size.Height)
}
Write("fixtures/test_extend_white_out.jpg", newImg)
}
func TestEmbedExtendWithCustomColor(t *testing.T) {
options := Options{Width: 400, Height: 600, Crop: false, Embed: true, Extend: 5, Background: Color{255, 20, 10}}
buf, _ := Read("fixtures/test_issue.jpg")
newImg, err := Resize(buf, options)
if err != nil {
t.Errorf("Resize(imgData, %#v) error: %#v", options, err)
}
size, _ := Size(newImg)
if size.Height != options.Height || size.Width != options.Width {
t.Fatalf("Invalid image size: %dx%d", size.Width, size.Height)
}
Write("fixtures/test_extend_background_out.jpg", newImg)
}
func TestGaussianBlur(t *testing.T) {
options := Options{Width: 800, Height: 600, GaussianBlur: GaussianBlur{Sigma: 5}}
buf, _ := Read("fixtures/test.jpg")