| 1 |
package imgkit_test |
| 2 |
|
| 3 |
import ( |
| 4 |
"image" |
| 5 |
"testing" |
| 6 |
|
| 7 |
"github.com/stretchr/testify/assert" |
| 8 |
|
| 9 |
"github.com/yeqown/go-qrcode/writer/standard/imgkit" |
| 10 |
) |
| 11 |
|
| 12 |
func Test_Gray(t *testing.T) { |
| 13 |
t.Skipf("need human to check") |
| 14 |
|
| 15 |
img, err := imgkit.Read("testdata/test.png") |
| 16 |
assert.NoError(t, err) |
| 17 |
|
| 18 |
out := imgkit.Gray(img) |
| 19 |
assert.Equal(t, out.Bounds(), img.Bounds()) |
| 20 |
imgkit.Save(out, "testdata/test_gray.png") |
| 21 |
} |
| 22 |
|
| 23 |
func TestBinaryzation(t *testing.T) { |
| 24 |
t.Skipf("need human to check") |
| 25 |
|
| 26 |
img, err := imgkit.Read("testdata/test.png") |
| 27 |
assert.NoError(t, err) |
| 28 |
|
| 29 |
out := imgkit.Binaryzation(img, 60) |
| 30 |
assert.Equal(t, out.Bounds(), img.Bounds()) |
| 31 |
err = imgkit.Save(out, "testdata/test_binaryzation.png") |
| 32 |
assert.NoError(t, err) |
| 33 |
} |
| 34 |
|
| 35 |
func TestScale(t *testing.T) { |
| 36 |
t.Skipf("need human to check") |
| 37 |
|
| 38 |
img, err := imgkit.Read("testdata/test_binaryzation.png") |
| 39 |
assert.NoError(t, err) |
| 40 |
|
| 41 |
out := imgkit.Scale(img, image.Rect(0, 0, 100, 100), nil) |
| 42 |
assert.Equal(t, out.Bounds(), image.Rect(0, 0, 100, 100)) |
| 43 |
err = imgkit.Save(out, "testdata/test_binaryzation_scale.png") |
| 44 |
assert.NoError(t, err) |
| 45 |
} |