summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/disintegration
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-05-12 23:56:07 -0400
committerChristopher Speller <crspeller@gmail.com>2016-05-12 23:56:07 -0400
commit38ee83e45b4de7edf89bf9f0ef629eb4c6ad0fa8 (patch)
treea4fde09672192b97d453ad605b030bd5a10c5a45 /vendor/github.com/disintegration
parent84d2482ddbff9564c9ad75b2d30af66e3ddfd44d (diff)
downloadchat-38ee83e45b4de7edf89bf9f0ef629eb4c6ad0fa8.tar.gz
chat-38ee83e45b4de7edf89bf9f0ef629eb4c6ad0fa8.tar.bz2
chat-38ee83e45b4de7edf89bf9f0ef629eb4c6ad0fa8.zip
Moving to glide
Diffstat (limited to 'vendor/github.com/disintegration')
-rw-r--r--vendor/github.com/disintegration/imaging/adjust_test.go504
-rw-r--r--vendor/github.com/disintegration/imaging/effects_test.go190
-rw-r--r--vendor/github.com/disintegration/imaging/helpers_test.go399
-rw-r--r--vendor/github.com/disintegration/imaging/resize_test.go570
-rw-r--r--vendor/github.com/disintegration/imaging/tools_test.go652
-rw-r--r--vendor/github.com/disintegration/imaging/transform_test.go261
-rw-r--r--vendor/github.com/disintegration/imaging/utils_test.go81
7 files changed, 2657 insertions, 0 deletions
diff --git a/vendor/github.com/disintegration/imaging/adjust_test.go b/vendor/github.com/disintegration/imaging/adjust_test.go
new file mode 100644
index 000000000..99898b0dc
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/adjust_test.go
@@ -0,0 +1,504 @@
+package imaging
+
+import (
+ "image"
+ "testing"
+)
+
+func TestGrayscale(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ want *image.NRGBA
+ }{
+ {
+ "Grayscale 3x3",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x3d, 0x3d, 0x3d, 0x01, 0x78, 0x78, 0x78, 0x02, 0x17, 0x17, 0x17, 0x03,
+ 0x1f, 0x1f, 0x1f, 0xff, 0x25, 0x25, 0x25, 0xff, 0x66, 0x66, 0x66, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := Grayscale(d.src)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestInvert(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ want *image.NRGBA
+ }{
+ {
+ "Invert 3x3",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x33, 0xff, 0xff, 0x01, 0xff, 0x33, 0xff, 0x02, 0xff, 0xff, 0x33, 0x03,
+ 0xee, 0xdd, 0xcc, 0xff, 0xcc, 0xdd, 0xee, 0xff, 0x55, 0xcc, 0x44, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0xff, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := Invert(d.src)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestAdjustContrast(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ p float64
+ want *image.NRGBA
+ }{
+ {
+ "AdjustContrast 3x3 10",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ 10,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xd5, 0x00, 0x00, 0x01, 0x00, 0xd5, 0x00, 0x02, 0x00, 0x00, 0xd5, 0x03,
+ 0x05, 0x18, 0x2b, 0xff, 0x2b, 0x18, 0x05, 0xff, 0xaf, 0x2b, 0xc2, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x2b, 0x2b, 0x2b, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ },
+ {
+ "AdjustContrast 3x3 100",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ 100,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xff, 0x00, 0x00, 0x01, 0x00, 0xff, 0x00, 0x02, 0x00, 0x00, 0xff, 0x03,
+ 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ },
+ {
+ "AdjustContrast 3x3 -10",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ -10,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xc4, 0x0d, 0x0d, 0x01, 0x0d, 0xc4, 0x0d, 0x02, 0x0d, 0x0d, 0xc4, 0x03,
+ 0x1c, 0x2b, 0x3b, 0xff, 0x3b, 0x2b, 0x1c, 0xff, 0xa6, 0x3b, 0xb5, 0xff,
+ 0x0d, 0x0d, 0x0d, 0xff, 0x3b, 0x3b, 0x3b, 0xff, 0xf2, 0xf2, 0xf2, 0xff,
+ },
+ },
+ },
+ {
+ "AdjustContrast 3x3 -100",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ -100,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x80, 0x80, 0x80, 0x01, 0x80, 0x80, 0x80, 0x02, 0x80, 0x80, 0x80, 0x03,
+ 0x80, 0x80, 0x80, 0xff, 0x80, 0x80, 0x80, 0xff, 0x80, 0x80, 0x80, 0xff,
+ 0x80, 0x80, 0x80, 0xff, 0x80, 0x80, 0x80, 0xff, 0x80, 0x80, 0x80, 0xff,
+ },
+ },
+ },
+ {
+ "AdjustContrast 3x3 0",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ 0,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := AdjustContrast(d.src, d.p)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestAdjustBrightness(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ p float64
+ want *image.NRGBA
+ }{
+ {
+ "AdjustBrightness 3x3 10",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ 10,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xe6, 0x1a, 0x1a, 0x01, 0x1a, 0xe6, 0x1a, 0x02, 0x1a, 0x1a, 0xe6, 0x03,
+ 0x2b, 0x3c, 0x4d, 0xff, 0x4d, 0x3c, 0x2b, 0xff, 0xc4, 0x4d, 0xd5, 0xff,
+ 0x1a, 0x1a, 0x1a, 0xff, 0x4d, 0x4d, 0x4d, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ },
+ {
+ "AdjustBrightness 3x3 100",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ 100,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x03,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ },
+ {
+ "AdjustBrightness 3x3 -10",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ -10,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xb3, 0x00, 0x00, 0x01, 0x00, 0xb3, 0x00, 0x02, 0x00, 0x00, 0xb3, 0x03,
+ 0x00, 0x09, 0x1a, 0xff, 0x1a, 0x09, 0x00, 0xff, 0x91, 0x1a, 0xa2, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x1a, 0x1a, 0x1a, 0xff, 0xe6, 0xe6, 0xe6, 0xff,
+ },
+ },
+ },
+ {
+ "AdjustBrightness 3x3 -100",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ -100,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03,
+ 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ },
+ {
+ "AdjustBrightness 3x3 0",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ 0,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := AdjustBrightness(d.src, d.p)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestAdjustGamma(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ p float64
+ want *image.NRGBA
+ }{
+ {
+ "AdjustGamma 3x3 0.75",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ 0.75,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xbd, 0x00, 0x00, 0x01, 0x00, 0xbd, 0x00, 0x02, 0x00, 0x00, 0xbd, 0x03,
+ 0x07, 0x11, 0x1e, 0xff, 0x1e, 0x11, 0x07, 0xff, 0x95, 0x1e, 0xa9, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x1e, 0x1e, 0x1e, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ },
+ {
+ "AdjustGamma 3x3 1.5",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ 1.5,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xdc, 0x00, 0x00, 0x01, 0x00, 0xdc, 0x00, 0x02, 0x00, 0x00, 0xdc, 0x03,
+ 0x2a, 0x43, 0x57, 0xff, 0x57, 0x43, 0x2a, 0xff, 0xc3, 0x57, 0xcf, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x57, 0x57, 0x57, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ },
+ {
+ "AdjustGamma 3x3 1.0",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ 1.0,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := AdjustGamma(d.src, d.p)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestAdjustSigmoid(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ m float64
+ p float64
+ want *image.NRGBA
+ }{
+ {
+ "AdjustSigmoid 3x3 0.5 3.0",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ 0.5,
+ 3.0,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xd4, 0x00, 0x00, 0x01, 0x00, 0xd4, 0x00, 0x02, 0x00, 0x00, 0xd4, 0x03,
+ 0x0d, 0x1b, 0x2b, 0xff, 0x2b, 0x1b, 0x0d, 0xff, 0xb1, 0x2b, 0xc3, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x2b, 0x2b, 0x2b, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ },
+ {
+ "AdjustSigmoid 3x3 0.5 -3.0",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ 0.5,
+ -3.0,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xc4, 0x00, 0x00, 0x01, 0x00, 0xc4, 0x00, 0x02, 0x00, 0x00, 0xc4, 0x03,
+ 0x16, 0x2a, 0x3b, 0xff, 0x3b, 0x2a, 0x16, 0xff, 0xa4, 0x3b, 0xb3, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x3b, 0x3b, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ },
+ {
+ "AdjustSigmoid 3x3 0.5 0.0",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ 0.5,
+ 0.0,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0x00, 0x00, 0x01, 0x00, 0xcc, 0x00, 0x02, 0x00, 0x00, 0xcc, 0x03,
+ 0x11, 0x22, 0x33, 0xff, 0x33, 0x22, 0x11, 0xff, 0xaa, 0x33, 0xbb, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := AdjustSigmoid(d.src, d.m, d.p)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
diff --git a/vendor/github.com/disintegration/imaging/effects_test.go b/vendor/github.com/disintegration/imaging/effects_test.go
new file mode 100644
index 000000000..a7e8cfffe
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/effects_test.go
@@ -0,0 +1,190 @@
+package imaging
+
+import (
+ "image"
+ "testing"
+)
+
+func TestBlur(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ sigma float64
+ want *image.NRGBA
+ }{
+ {
+ "Blur 3x3 0",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x66, 0xaa, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ },
+ },
+ 0.0,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x66, 0xaa, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ },
+ },
+ },
+ {
+ "Blur 3x3 0.5",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x66, 0xaa, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ },
+ },
+ 0.5,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x01, 0x02, 0x04, 0x04, 0x0a, 0x10, 0x18, 0x18, 0x01, 0x02, 0x04, 0x04,
+ 0x09, 0x10, 0x18, 0x18, 0x3f, 0x69, 0x9e, 0x9e, 0x09, 0x10, 0x18, 0x18,
+ 0x01, 0x02, 0x04, 0x04, 0x0a, 0x10, 0x18, 0x18, 0x01, 0x02, 0x04, 0x04,
+ },
+ },
+ },
+ {
+ "Blur 3x3 10",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x66, 0xaa, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ },
+ },
+ 10,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x0b, 0x13, 0x1c, 0x1c, 0x0b, 0x13, 0x1c, 0x1c, 0x0b, 0x13, 0x1c, 0x1c,
+ 0x0b, 0x13, 0x1c, 0x1c, 0x0b, 0x13, 0x1c, 0x1c, 0x0b, 0x13, 0x1c, 0x1c,
+ 0x0b, 0x13, 0x1c, 0x1c, 0x0b, 0x13, 0x1c, 0x1c, 0x0b, 0x13, 0x1c, 0x1c,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := Blur(d.src, d.sigma)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestSharpen(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ sigma float64
+ want *image.NRGBA
+ }{
+ {
+ "Sharpen 3x3 0",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
+ 0x66, 0x66, 0x66, 0x66, 0x77, 0x77, 0x77, 0x77, 0x66, 0x66, 0x66, 0x66,
+ 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
+ },
+ },
+ 0,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
+ 0x66, 0x66, 0x66, 0x66, 0x77, 0x77, 0x77, 0x77, 0x66, 0x66, 0x66, 0x66,
+ 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
+ },
+ },
+ },
+ {
+ "Sharpen 3x3 0.5",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
+ 0x66, 0x66, 0x66, 0x66, 0x77, 0x77, 0x77, 0x77, 0x66, 0x66, 0x66, 0x66,
+ 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
+ },
+ },
+ 0.5,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x66, 0x66, 0x66, 0x66, 0x64, 0x64, 0x64, 0x64, 0x66, 0x66, 0x66, 0x66,
+ 0x64, 0x64, 0x64, 0x64, 0x7e, 0x7e, 0x7e, 0x7e, 0x64, 0x64, 0x64, 0x64,
+ 0x66, 0x66, 0x66, 0x66, 0x64, 0x64, 0x64, 0x64, 0x66, 0x66, 0x66, 0x66,
+ },
+ },
+ },
+ {
+ "Sharpen 3x3 100",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
+ 0x66, 0x66, 0x66, 0x66, 0x77, 0x77, 0x77, 0x77, 0x66, 0x66, 0x66, 0x66,
+ 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
+ },
+ },
+ 100,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64,
+ 0x64, 0x64, 0x64, 0x64, 0x86, 0x86, 0x86, 0x86, 0x64, 0x64, 0x64, 0x64,
+ 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64,
+ },
+ },
+ },
+ {
+ "Sharpen 3x1 10",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 0),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ 10,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 1),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := Sharpen(d.src, d.sigma)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
diff --git a/vendor/github.com/disintegration/imaging/helpers_test.go b/vendor/github.com/disintegration/imaging/helpers_test.go
new file mode 100644
index 000000000..1287ec588
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/helpers_test.go
@@ -0,0 +1,399 @@
+package imaging
+
+import (
+ "bytes"
+ "image"
+ "image/color"
+ "testing"
+)
+
+func compareNRGBA(img1, img2 *image.NRGBA, delta int) bool {
+ if !img1.Rect.Eq(img2.Rect) {
+ return false
+ }
+
+ if len(img1.Pix) != len(img2.Pix) {
+ return false
+ }
+
+ for i := 0; i < len(img1.Pix); i++ {
+ if absint(int(img1.Pix[i])-int(img2.Pix[i])) > delta {
+ return false
+ }
+ }
+
+ return true
+}
+
+func TestEncodeDecode(t *testing.T) {
+ imgWithAlpha := image.NewNRGBA(image.Rect(0, 0, 3, 3))
+ imgWithAlpha.Pix = []uint8{
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
+ 244, 245, 246, 247, 248, 249, 250, 252, 252, 253, 254, 255,
+ }
+
+ imgWithoutAlpha := image.NewNRGBA(image.Rect(0, 0, 3, 3))
+ imgWithoutAlpha.Pix = []uint8{
+ 0, 1, 2, 255, 4, 5, 6, 255, 8, 9, 10, 255,
+ 127, 128, 129, 255, 131, 132, 133, 255, 135, 136, 137, 255,
+ 244, 245, 246, 255, 248, 249, 250, 255, 252, 253, 254, 255,
+ }
+
+ for _, format := range []Format{JPEG, PNG, GIF, BMP, TIFF} {
+ img := imgWithoutAlpha
+ if format == PNG {
+ img = imgWithAlpha
+ }
+
+ buf := &bytes.Buffer{}
+ err := Encode(buf, img, format)
+ if err != nil {
+ t.Errorf("fail encoding format %s", format)
+ continue
+ }
+
+ img2, err := Decode(buf)
+ if err != nil {
+ t.Errorf("fail decoding format %s", format)
+ continue
+ }
+ img2cloned := Clone(img2)
+
+ delta := 0
+ if format == JPEG {
+ delta = 3
+ } else if format == GIF {
+ delta = 16
+ }
+
+ if !compareNRGBA(img, img2cloned, delta) {
+ t.Errorf("test [DecodeEncode %s] failed: %#v %#v", format, img, img2cloned)
+ continue
+ }
+ }
+
+ buf := &bytes.Buffer{}
+ err := Encode(buf, imgWithAlpha, JPEG)
+ if err != nil {
+ t.Errorf("failed encoding alpha to JPEG format %s", err)
+ }
+
+ buf = &bytes.Buffer{}
+ err = Encode(buf, imgWithAlpha, Format(100))
+ if err != ErrUnsupportedFormat {
+ t.Errorf("expected ErrUnsupportedFormat")
+ }
+
+ buf = bytes.NewBuffer([]byte("bad data"))
+ _, err = Decode(buf)
+ if err == nil {
+ t.Errorf("decoding bad data, expected error")
+ }
+}
+
+func TestNew(t *testing.T) {
+ td := []struct {
+ desc string
+ w, h int
+ c color.Color
+ dstBounds image.Rectangle
+ dstPix []uint8
+ }{
+ {
+ "New 1x1 black",
+ 1, 1,
+ color.NRGBA{0, 0, 0, 0},
+ image.Rect(0, 0, 1, 1),
+ []uint8{0x00, 0x00, 0x00, 0x00},
+ },
+ {
+ "New 1x2 red",
+ 1, 2,
+ color.NRGBA{255, 0, 0, 255},
+ image.Rect(0, 0, 1, 2),
+ []uint8{0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff},
+ },
+ {
+ "New 2x1 white",
+ 2, 1,
+ color.NRGBA{255, 255, 255, 255},
+ image.Rect(0, 0, 2, 1),
+ []uint8{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
+ },
+ {
+ "New 0x0 white",
+ 0, 0,
+ color.NRGBA{255, 255, 255, 255},
+ image.Rect(0, 0, 0, 0),
+ nil,
+ },
+ }
+
+ for _, d := range td {
+ got := New(d.w, d.h, d.c)
+ want := image.NewNRGBA(d.dstBounds)
+ want.Pix = d.dstPix
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestClone(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ want *image.NRGBA
+ }{
+ {
+ "Clone NRGBA",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 0, 1),
+ Stride: 1 * 4,
+ Pix: []uint8{0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff},
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 1, 2),
+ Stride: 1 * 4,
+ Pix: []uint8{0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff},
+ },
+ },
+ {
+ "Clone NRGBA64",
+ &image.NRGBA64{
+ Rect: image.Rect(-1, -1, 0, 1),
+ Stride: 1 * 8,
+ Pix: []uint8{
+ 0x00, 0x00, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33,
+ 0xcc, 0xcc, 0xdd, 0xdd, 0xee, 0xee, 0xff, 0xff,
+ },
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 1, 2),
+ Stride: 1 * 4,
+ Pix: []uint8{0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff},
+ },
+ },
+ {
+ "Clone RGBA",
+ &image.RGBA{
+ Rect: image.Rect(-1, -1, 0, 2),
+ Stride: 1 * 4,
+ Pix: []uint8{0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff},
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 1, 3),
+ Stride: 1 * 4,
+ Pix: []uint8{0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa, 0x33, 0xcc, 0xdd, 0xee, 0xff},
+ },
+ },
+ {
+ "Clone RGBA64",
+ &image.RGBA64{
+ Rect: image.Rect(-1, -1, 0, 2),
+ Stride: 1 * 8,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33,
+ 0xcc, 0xcc, 0xdd, 0xdd, 0xee, 0xee, 0xff, 0xff,
+ },
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 1, 3),
+ Stride: 1 * 4,
+ Pix: []uint8{0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa, 0x33, 0xcc, 0xdd, 0xee, 0xff},
+ },
+ },
+ {
+ "Clone Gray",
+ &image.Gray{
+ Rect: image.Rect(-1, -1, 0, 1),
+ Stride: 1 * 1,
+ Pix: []uint8{0x11, 0xee},
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 1, 2),
+ Stride: 1 * 4,
+ Pix: []uint8{0x11, 0x11, 0x11, 0xff, 0xee, 0xee, 0xee, 0xff},
+ },
+ },
+ {
+ "Clone Gray16",
+ &image.Gray16{
+ Rect: image.Rect(-1, -1, 0, 1),
+ Stride: 1 * 2,
+ Pix: []uint8{0x11, 0x11, 0xee, 0xee},
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 1, 2),
+ Stride: 1 * 4,
+ Pix: []uint8{0x11, 0x11, 0x11, 0xff, 0xee, 0xee, 0xee, 0xff},
+ },
+ },
+ {
+ "Clone Alpha",
+ &image.Alpha{
+ Rect: image.Rect(-1, -1, 0, 1),
+ Stride: 1 * 1,
+ Pix: []uint8{0x11, 0xee},
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 1, 2),
+ Stride: 1 * 4,
+ Pix: []uint8{0xff, 0xff, 0xff, 0x11, 0xff, 0xff, 0xff, 0xee},
+ },
+ },
+ {
+ "Clone YCbCr",
+ &image.YCbCr{
+ Rect: image.Rect(-1, -1, 5, 0),
+ SubsampleRatio: image.YCbCrSubsampleRatio444,
+ YStride: 6,
+ CStride: 6,
+ Y: []uint8{0x00, 0xff, 0x7f, 0x26, 0x4b, 0x0e},
+ Cb: []uint8{0x80, 0x80, 0x80, 0x6b, 0x56, 0xc0},
+ Cr: []uint8{0x80, 0x80, 0x80, 0xc0, 0x4b, 0x76},
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 6, 1),
+ Stride: 6 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0x7f, 0x7f, 0x7f, 0xff,
+ 0x7f, 0x00, 0x00, 0xff,
+ 0x00, 0x7f, 0x00, 0xff,
+ 0x00, 0x00, 0x7f, 0xff,
+ },
+ },
+ },
+ {
+ "Clone YCbCr 444",
+ &image.YCbCr{
+ Y: []uint8{0x4c, 0x69, 0x1d, 0xb1, 0x96, 0xe2, 0x26, 0x34, 0xe, 0x59, 0x4b, 0x71, 0x0, 0x4c, 0x99, 0xff},
+ Cb: []uint8{0x55, 0xd4, 0xff, 0x8e, 0x2c, 0x01, 0x6b, 0xaa, 0xc0, 0x95, 0x56, 0x40, 0x80, 0x80, 0x80, 0x80},
+ Cr: []uint8{0xff, 0xeb, 0x6b, 0x36, 0x15, 0x95, 0xc0, 0xb5, 0x76, 0x41, 0x4b, 0x8c, 0x80, 0x80, 0x80, 0x80},
+ YStride: 4,
+ CStride: 4,
+ SubsampleRatio: image.YCbCrSubsampleRatio444,
+ Rect: image.Rectangle{Min: image.Point{X: 0, Y: 0}, Max: image.Point{X: 4, Y: 4}},
+ },
+ &image.NRGBA{
+ Pix: []uint8{0xff, 0x0, 0x0, 0xff, 0xff, 0x0, 0xff, 0xff, 0x0, 0x0, 0xff, 0xff, 0x49, 0xe1, 0xca, 0xff, 0x0, 0xff, 0x0, 0xff, 0xff, 0xff, 0x0, 0xff, 0x7f, 0x0, 0x0, 0xff, 0x7f, 0x0, 0x7f, 0xff, 0x0, 0x0, 0x7f, 0xff, 0x0, 0x7f, 0x7f, 0xff, 0x0, 0x7f, 0x0, 0xff, 0x82, 0x7f, 0x0, 0xff, 0x0, 0x0, 0x0, 0xff, 0x4c, 0x4c, 0x4c, 0xff, 0x99, 0x99, 0x99, 0xff, 0xff, 0xff, 0xff, 0xff},
+ Stride: 16,
+ Rect: image.Rectangle{Min: image.Point{X: 0, Y: 0}, Max: image.Point{X: 4, Y: 4}},
+ },
+ },
+ {
+ "Clone YCbCr 440",
+ &image.YCbCr{
+ Y: []uint8{0x4c, 0x69, 0x1d, 0xb1, 0x96, 0xe2, 0x26, 0x34, 0xe, 0x59, 0x4b, 0x71, 0x0, 0x4c, 0x99, 0xff},
+ Cb: []uint8{0x2c, 0x01, 0x6b, 0xaa, 0x80, 0x80, 0x80, 0x80},
+ Cr: []uint8{0x15, 0x95, 0xc0, 0xb5, 0x80, 0x80, 0x80, 0x80},
+ YStride: 4,
+ CStride: 4,
+ SubsampleRatio: image.YCbCrSubsampleRatio440,
+ Rect: image.Rectangle{Min: image.Point{X: 0, Y: 0}, Max: image.Point{X: 4, Y: 4}},
+ },
+ &image.NRGBA{
+ Pix: []uint8{0x0, 0xb5, 0x0, 0xff, 0x86, 0x86, 0x0, 0xff, 0x77, 0x0, 0x0, 0xff, 0xfb, 0x7d, 0xfb, 0xff, 0x0, 0xff, 0x1, 0xff, 0xff, 0xff, 0x1, 0xff, 0x80, 0x0, 0x1, 0xff, 0x7e, 0x0, 0x7e, 0xff, 0xe, 0xe, 0xe, 0xff, 0x59, 0x59, 0x59, 0xff, 0x4b, 0x4b, 0x4b, 0xff, 0x71, 0x71, 0x71, 0xff, 0x0, 0x0, 0x0, 0xff, 0x4c, 0x4c, 0x4c, 0xff, 0x99, 0x99, 0x99, 0xff, 0xff, 0xff, 0xff, 0xff},
+ Stride: 16,
+ Rect: image.Rectangle{Min: image.Point{X: 0, Y: 0}, Max: image.Point{X: 4, Y: 4}},
+ },
+ },
+ {
+ "Clone YCbCr 422",
+ &image.YCbCr{
+ Y: []uint8{0x4c, 0x69, 0x1d, 0xb1, 0x96, 0xe2, 0x26, 0x34, 0xe, 0x59, 0x4b, 0x71, 0x0, 0x4c, 0x99, 0xff},
+ Cb: []uint8{0xd4, 0x8e, 0x01, 0xaa, 0x95, 0x40, 0x80, 0x80},
+ Cr: []uint8{0xeb, 0x36, 0x95, 0xb5, 0x41, 0x8c, 0x80, 0x80},
+ YStride: 4,
+ CStride: 2,
+ SubsampleRatio: image.YCbCrSubsampleRatio422,
+ Rect: image.Rectangle{Min: image.Point{X: 0, Y: 0}, Max: image.Point{X: 4, Y: 4}},
+ },
+ &image.NRGBA{
+ Pix: []uint8{0xe2, 0x0, 0xe1, 0xff, 0xff, 0x0, 0xfe, 0xff, 0x0, 0x4d, 0x36, 0xff, 0x49, 0xe1, 0xca, 0xff, 0xb3, 0xb3, 0x0, 0xff, 0xff, 0xff, 0x1, 0xff, 0x70, 0x0, 0x70, 0xff, 0x7e, 0x0, 0x7e, 0xff, 0x0, 0x34, 0x33, 0xff, 0x1, 0x7f, 0x7e, 0xff, 0x5c, 0x58, 0x0, 0xff, 0x82, 0x7e, 0x0, 0xff, 0x0, 0x0, 0x0, 0xff, 0x4c, 0x4c, 0x4c, 0xff, 0x99, 0x99, 0x99, 0xff, 0xff, 0xff, 0xff, 0xff},
+ Stride: 16,
+ Rect: image.Rectangle{Min: image.Point{X: 0, Y: 0}, Max: image.Point{X: 4, Y: 4}},
+ },
+ },
+ {
+ "Clone YCbCr 420",
+ &image.YCbCr{
+ Y: []uint8{0x4c, 0x69, 0x1d, 0xb1, 0x96, 0xe2, 0x26, 0x34, 0xe, 0x59, 0x4b, 0x71, 0x0, 0x4c, 0x99, 0xff},
+ Cb: []uint8{0x01, 0xaa, 0x80, 0x80},
+ Cr: []uint8{0x95, 0xb5, 0x80, 0x80},
+ YStride: 4, CStride: 2,
+ SubsampleRatio: image.YCbCrSubsampleRatio420,
+ Rect: image.Rectangle{Min: image.Point{X: 0, Y: 0}, Max: image.Point{X: 4, Y: 4}},
+ },
+ &image.NRGBA{
+ Pix: []uint8{0x69, 0x69, 0x0, 0xff, 0x86, 0x86, 0x0, 0xff, 0x67, 0x0, 0x67, 0xff, 0xfb, 0x7d, 0xfb, 0xff, 0xb3, 0xb3, 0x0, 0xff, 0xff, 0xff, 0x1, 0xff, 0x70, 0x0, 0x70, 0xff, 0x7e, 0x0, 0x7e, 0xff, 0xe, 0xe, 0xe, 0xff, 0x59, 0x59, 0x59, 0xff, 0x4b, 0x4b, 0x4b, 0xff, 0x71, 0x71, 0x71, 0xff, 0x0, 0x0, 0x0, 0xff, 0x4c, 0x4c, 0x4c, 0xff, 0x99, 0x99, 0x99, 0xff, 0xff, 0xff, 0xff, 0xff},
+ Stride: 16,
+ Rect: image.Rectangle{Min: image.Point{X: 0, Y: 0}, Max: image.Point{X: 4, Y: 4}},
+ },
+ },
+ {
+ "Clone Paletted",
+ &image.Paletted{
+ Rect: image.Rect(-1, -1, 5, 0),
+ Stride: 6 * 1,
+ Palette: color.Palette{
+ color.NRGBA{R: 0x00, G: 0x00, B: 0x00, A: 0xff},
+ color.NRGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff},
+ color.NRGBA{R: 0x7f, G: 0x7f, B: 0x7f, A: 0xff},
+ color.NRGBA{R: 0x7f, G: 0x00, B: 0x00, A: 0xff},
+ color.NRGBA{R: 0x00, G: 0x7f, B: 0x00, A: 0xff},
+ color.NRGBA{R: 0x00, G: 0x00, B: 0x7f, A: 0xff},
+ },
+ Pix: []uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5},
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 6, 1),
+ Stride: 6 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ 0x7f, 0x7f, 0x7f, 0xff,
+ 0x7f, 0x00, 0x00, 0xff,
+ 0x00, 0x7f, 0x00, 0xff,
+ 0x00, 0x00, 0x7f, 0xff,
+ },
+ },
+ },
+ }
+
+ for _, d := range td {
+ got := Clone(d.src)
+ want := d.want
+
+ delta := 0
+ if _, ok := d.src.(*image.YCbCr); ok {
+ delta = 1
+ }
+
+ if !compareNRGBA(got, want, delta) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestFormats(t *testing.T) {
+ formatNames := map[Format]string{
+ JPEG: "JPEG",
+ PNG: "PNG",
+ GIF: "GIF",
+ BMP: "BMP",
+ TIFF: "TIFF",
+ Format(-1): "Unsupported",
+ }
+ for format, name := range formatNames {
+ got := format.String()
+ if got != name {
+ t.Errorf("test [Format names] failed: got %#v want %#v", got, name)
+ continue
+ }
+ }
+}
diff --git a/vendor/github.com/disintegration/imaging/resize_test.go b/vendor/github.com/disintegration/imaging/resize_test.go
new file mode 100644
index 000000000..08d7f2d85
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/resize_test.go
@@ -0,0 +1,570 @@
+package imaging
+
+import (
+ "image"
+ "testing"
+)
+
+func TestResize(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ w, h int
+ f ResampleFilter
+ want *image.NRGBA
+ }{
+ {
+ "Resize 2x2 1x1 box",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 1),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff,
+ },
+ },
+ 1, 1,
+ Box,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 1, 1),
+ Stride: 1 * 4,
+ Pix: []uint8{0x40, 0x40, 0x40, 0xc0},
+ },
+ },
+ {
+ "Resize 2x2 2x2 box",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 1),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff,
+ },
+ },
+ 2, 2,
+ Box,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff,
+ },
+ },
+ },
+ {
+ "Resize 3x1 1x1 nearest",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 0),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff,
+ },
+ },
+ 1, 1,
+ NearestNeighbor,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 1, 1),
+ Stride: 1 * 4,
+ Pix: []uint8{0x00, 0xff, 0x00, 0xff},
+ },
+ },
+ {
+ "Resize 2x2 0x4 box",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 1),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff,
+ },
+ },
+ 0, 4,
+ Box,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 4, 4),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff,
+ },
+ },
+ },
+ {
+ "Resize 2x2 4x0 linear",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 1),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff,
+ },
+ },
+ 4, 0,
+ Linear,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 4, 4),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x40, 0xbf, 0x00, 0x00, 0xbf, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0x40, 0x00, 0x40, 0x30, 0x30, 0x10, 0x70, 0x8f, 0x10, 0x30, 0xcf, 0xbf, 0x00, 0x40, 0xff,
+ 0x00, 0xbf, 0x00, 0xbf, 0x10, 0x8f, 0x30, 0xcf, 0x30, 0x30, 0x8f, 0xef, 0x40, 0x00, 0xbf, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0xbf, 0x40, 0xff, 0x00, 0x40, 0xbf, 0xff, 0x00, 0x00, 0xff, 0xff,
+ },
+ },
+ },
+ {
+ "Resize 0x0 1x1 box",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, -1, -1),
+ Stride: 0,
+ Pix: []uint8{},
+ },
+ 1, 1,
+ Box,
+ &image.NRGBA{},
+ },
+ {
+ "Resize 2x2 0x0 box",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 1),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff,
+ },
+ },
+ 0, 0,
+ Box,
+ &image.NRGBA{},
+ },
+ {
+ "Resize 2x2 -1x0 box",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 1),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff,
+ },
+ },
+ -1, 0,
+ Box,
+ &image.NRGBA{},
+ },
+ }
+ for _, d := range td {
+ got := Resize(d.src, d.w, d.h, d.f)
+ want := d.want
+ if !compareNRGBA(got, want, 1) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+
+ for i, filter := range []ResampleFilter{
+ NearestNeighbor,
+ Box,
+ Linear,
+ Hermite,
+ MitchellNetravali,
+ CatmullRom,
+ BSpline,
+ Gaussian,
+ Lanczos,
+ Hann,
+ Hamming,
+ Blackman,
+ Bartlett,
+ Welch,
+ Cosine,
+ } {
+ src := image.NewNRGBA(image.Rect(-1, -1, 2, 3))
+ got := Resize(src, 5, 6, filter)
+ want := image.NewNRGBA(image.Rect(0, 0, 5, 6))
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [Resize all filters #%d] failed: %#v", i, got)
+ }
+
+ if filter.Kernel != nil {
+ x := filter.Kernel(filter.Support + 0.0001)
+ if x != 0 {
+ t.Errorf("test [ResampleFilter edge cases #%d] failed: %f", i, x)
+ }
+ }
+ }
+
+ bcs2 := bcspline(2, 1, 0)
+ if bcs2 != 0 {
+ t.Errorf("test [bcspline 2] failed: %f", bcs2)
+ }
+}
+
+func TestFit(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ w, h int
+ f ResampleFilter
+ want *image.NRGBA
+ }{
+ {
+ "Fit 2x2 1x10 box",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 1),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff,
+ },
+ },
+ 1, 10,
+ Box,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 1, 1),
+ Stride: 1 * 4,
+ Pix: []uint8{0x40, 0x40, 0x40, 0xc0},
+ },
+ },
+ {
+ "Fit 2x2 10x1 box",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 1),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff,
+ },
+ },
+ 10, 1,
+ Box,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 1, 1),
+ Stride: 1 * 4,
+ Pix: []uint8{0x40, 0x40, 0x40, 0xc0},
+ },
+ },
+ {
+ "Fit 2x2 10x10 box",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 1),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff,
+ },
+ },
+ 10, 10,
+ Box,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff,
+ },
+ },
+ },
+ {
+ "Fit 0x0 1x1 box",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, -1, -1),
+ Stride: 0,
+ Pix: []uint8{},
+ },
+ 1, 1,
+ Box,
+ &image.NRGBA{},
+ },
+ {
+ "Fit 2x2 0x0 box",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 1),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff,
+ },
+ },
+ 0, 0,
+ Box,
+ &image.NRGBA{},
+ },
+ {
+ "Fit 2x2 -1x0 box",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 1),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff,
+ },
+ },
+ -1, 0,
+ Box,
+ &image.NRGBA{},
+ },
+ }
+ for _, d := range td {
+ got := Fit(d.src, d.w, d.h, d.f)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestFill(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ w, h int
+ a Anchor
+ f ResampleFilter
+ want *image.NRGBA
+ }{
+ {
+ "Fill 4x4 2x2 Center Nearest",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 2, 2,
+ Center,
+ NearestNeighbor,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x14, 0x15, 0x16, 0x17, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x34, 0x35, 0x36, 0x37, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ },
+ {
+ "Fill 4x4 1x4 TopLeft Nearest",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 1, 4,
+ TopLeft,
+ NearestNeighbor,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 1, 4),
+ Stride: 1 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03,
+ 0x10, 0x11, 0x12, 0x13,
+ 0x20, 0x21, 0x22, 0x23,
+ 0x30, 0x31, 0x32, 0x33,
+ },
+ },
+ },
+ {
+ "Fill 4x4 8x2 Bottom Nearest",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 8, 2,
+ Bottom,
+ NearestNeighbor,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 8, 2),
+ Stride: 8 * 4,
+ Pix: []uint8{
+ 0x30, 0x31, 0x32, 0x33, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x3c, 0x3d, 0x3e, 0x3f,
+ 0x30, 0x31, 0x32, 0x33, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ },
+ {
+ "Fill 4x4 2x8 Top Nearest",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 2, 8,
+ Top,
+ NearestNeighbor,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 8),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
+ 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
+ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
+ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
+ 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
+ 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
+ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
+ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
+ },
+ },
+ },
+ {
+ "Fill 4x4 4x4 TopRight Box",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 4, 4,
+ TopRight,
+ Box,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 4, 4),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ },
+ {
+ "Fill 4x4 0x4 Left Box",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 0, 4,
+ Left,
+ Box,
+ &image.NRGBA{},
+ },
+ {
+ "Fill 0x0 4x4 Right Box",
+ &image.NRGBA{},
+ 4, 4,
+ Right,
+ Box,
+ &image.NRGBA{},
+ },
+ }
+ for _, d := range td {
+ got := Fill(d.src, d.w, d.h, d.a, d.f)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestThumbnail(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ w, h int
+ f ResampleFilter
+ want *image.NRGBA
+ }{
+ {
+ "Thumbnail 6x2 1x1 box",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 5, 1),
+ Stride: 6 * 4,
+ Pix: []uint8{
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ 1, 1,
+ Box,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 1, 1),
+ Stride: 1 * 4,
+ Pix: []uint8{0x40, 0x40, 0x40, 0xc0},
+ },
+ },
+ {
+ "Thumbnail 2x6 1x1 box",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 5),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ 1, 1,
+ Box,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 1, 1),
+ Stride: 1 * 4,
+ Pix: []uint8{0x40, 0x40, 0x40, 0xc0},
+ },
+ },
+ {
+ "Thumbnail 1x3 2x2 box",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 0, 2),
+ Stride: 1 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0x00, 0x00, 0xff,
+ 0xff, 0xff, 0xff, 0xff,
+ },
+ },
+ 2, 2,
+ Box,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff,
+ 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := Thumbnail(d.src, d.w, d.h, d.f)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
diff --git a/vendor/github.com/disintegration/imaging/tools_test.go b/vendor/github.com/disintegration/imaging/tools_test.go
new file mode 100644
index 000000000..2ac7b31d3
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/tools_test.go
@@ -0,0 +1,652 @@
+package imaging
+
+import (
+ "image"
+ "testing"
+)
+
+func TestCrop(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ r image.Rectangle
+ want *image.NRGBA
+ }{
+ {
+ "Crop 2x3 2x1",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ image.Rect(-1, 0, 1, 1),
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 1),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := Crop(d.src, d.r)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestCropCenter(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ w, h int
+ want *image.NRGBA
+ }{
+ {
+ "CropCenter 2x3 2x1",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ 2, 1,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 1),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ },
+ },
+ },
+ {
+ "CropCenter 2x3 0x1",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ 0, 1,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 0, 0),
+ Stride: 0,
+ Pix: []uint8{},
+ },
+ },
+ {
+ "CropCenter 2x3 5x5",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ 5, 5,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 3),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := CropCenter(d.src, d.w, d.h)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestCropAnchor(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ w, h int
+ anchor Anchor
+ want *image.NRGBA
+ }{
+ {
+ "CropAnchor 4x4 2x2 TopLeft",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 2, 2,
+ TopLeft,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ },
+ },
+ },
+ {
+ "CropAnchor 4x4 2x2 Top",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 2, 2,
+ Top,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
+ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
+ },
+ },
+ },
+ {
+ "CropAnchor 4x4 2x2 TopRight",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 2, 2,
+ TopRight,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ },
+ },
+ },
+ {
+ "CropAnchor 4x4 2x2 Left",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 2, 2,
+ Left,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ },
+ },
+ },
+ {
+ "CropAnchor 4x4 2x2 Center",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 2, 2,
+ Center,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
+ 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
+ },
+ },
+ },
+ {
+ "CropAnchor 4x4 2x2 Right",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 2, 2,
+ Right,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ },
+ },
+ },
+ {
+ "CropAnchor 4x4 2x2 BottomLeft",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 2, 2,
+ BottomLeft,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ },
+ },
+ },
+ {
+ "CropAnchor 4x4 2x2 Bottom",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 2, 2,
+ Bottom,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
+ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
+ },
+ },
+ },
+ {
+ "CropAnchor 4x4 2x2 BottomRight",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 2, 2,
+ BottomRight,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ },
+ {
+ "CropAnchor 4x4 0x0 BottomRight",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 0, 0,
+ BottomRight,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 0, 0),
+ Stride: 0,
+ Pix: []uint8{},
+ },
+ },
+ {
+ "CropAnchor 4x4 100x100 BottomRight",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 100, 100,
+ BottomRight,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 4, 4),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ },
+ {
+ "CropAnchor 4x4 1x100 BottomRight",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 1, 100,
+ BottomRight,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 1, 4),
+ Stride: 1 * 4,
+ Pix: []uint8{
+ 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ },
+ {
+ "CropAnchor 4x4 0x100 BottomRight",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ 0, 100,
+ BottomRight,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 0, 0),
+ Stride: 0,
+ Pix: []uint8{},
+ },
+ },
+ }
+ for _, d := range td {
+ got := CropAnchor(d.src, d.w, d.h, d.anchor)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestPaste(t *testing.T) {
+ td := []struct {
+ desc string
+ src1 image.Image
+ src2 image.Image
+ p image.Point
+ want *image.NRGBA
+ }{
+ {
+ "Paste 2x3 2x1",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ &image.NRGBA{
+ Rect: image.Rect(1, 1, 3, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ },
+ },
+ image.Pt(-1, 0),
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 3),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := Paste(d.src1, d.src2, d.p)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestPasteCenter(t *testing.T) {
+ td := []struct {
+ desc string
+ src1 image.Image
+ src2 image.Image
+ want *image.NRGBA
+ }{
+ {
+ "PasteCenter 2x3 2x1",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ &image.NRGBA{
+ Rect: image.Rect(1, 1, 3, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ },
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 3),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := PasteCenter(d.src1, d.src2)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestOverlay(t *testing.T) {
+ td := []struct {
+ desc string
+ src1 image.Image
+ src2 image.Image
+ p image.Point
+ a float64
+ want *image.NRGBA
+ }{
+ {
+ "Overlay 2x3 2x1 1.0",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0x60, 0x00, 0x90, 0xff, 0xff, 0x00, 0x99, 0x7f,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ &image.NRGBA{
+ Rect: image.Rect(1, 1, 3, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x20, 0x40, 0x80, 0x7f, 0xaa, 0xbb, 0xcc, 0xff,
+ },
+ },
+ image.Pt(-1, 0),
+ 1.0,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 3),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0x40, 0x1f, 0x88, 0xff, 0xaa, 0xbb, 0xcc, 0xff,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ },
+ {
+ "Overlay 2x2 2x2 0.5",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 1),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
+ 0x00, 0x00, 0xff, 0xff, 0x20, 0x20, 0x20, 0x00,
+ },
+ },
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 1),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0x00, 0xff, 0x20, 0x20, 0x20, 0xff,
+ },
+ },
+ image.Pt(-1, -1),
+ 0.5,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0xff, 0x7f, 0x7f, 0xff, 0x00, 0xff, 0x00, 0xff,
+ 0x7f, 0x7f, 0x7f, 0xff, 0x20, 0x20, 0x20, 0x7f,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := Overlay(d.src1, d.src2, d.p, d.a)
+ want := d.want
+ if !compareNRGBA(got, want, 1) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestOverlayCenter(t *testing.T) {
+ td := []struct {
+ desc string
+ src1 image.Image
+ src2 image.Image
+ a float64
+ want *image.NRGBA
+ }{
+ {
+ "OverlayCenter 2x3 2x1",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x10, 0x10, 0x10, 0xff, 0x10, 0x10, 0x10, 0xff,
+ 0x10, 0x10, 0x10, 0xff, 0x10, 0x10, 0x10, 0xff,
+ 0x10, 0x10, 0x10, 0xff, 0x10, 0x10, 0x10, 0xff,
+ },
+ },
+ &image.NRGBA{
+ Rect: image.Rect(1, 1, 3, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
+ },
+ },
+ 0.5,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 3),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x10, 0x10, 0x10, 0xff, 0x10, 0x10, 0x10, 0xff,
+ 0x2c, 0x2c, 0x2c, 0xff, 0x2c, 0x2c, 0x2c, 0xff,
+ 0x10, 0x10, 0x10, 0xff, 0x10, 0x10, 0x10, 0xff,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := OverlayCenter(d.src1, d.src2, 0.5)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
diff --git a/vendor/github.com/disintegration/imaging/transform_test.go b/vendor/github.com/disintegration/imaging/transform_test.go
new file mode 100644
index 000000000..6e64082f4
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/transform_test.go
@@ -0,0 +1,261 @@
+package imaging
+
+import (
+ "image"
+ "testing"
+)
+
+func TestRotate90(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ want *image.NRGBA
+ }{
+ {
+ "Rotate90 2x3",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0xcc, 0xdd, 0xee, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
+ 0x00, 0x11, 0x22, 0x33, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := Rotate90(d.src)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestRotate180(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ want *image.NRGBA
+ }{
+ {
+ "Rotate180 2x3",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 3),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00,
+ 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
+ 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 0x22, 0x33,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := Rotate180(d.src)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestRotate270(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ want *image.NRGBA
+ }{
+ {
+ "Rotate270 2x3",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x11, 0x22, 0x33,
+ 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xcc, 0xdd, 0xee, 0xff,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := Rotate270(d.src)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestFlipV(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ want *image.NRGBA
+ }{
+ {
+ "FlipV 2x3",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 3),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := FlipV(d.src)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestFlipH(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ want *image.NRGBA
+ }{
+ {
+ "FlipH 2x3",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 2, 3),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 0x22, 0x33,
+ 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := FlipH(d.src)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestTranspose(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ want *image.NRGBA
+ }{
+ {
+ "Transpose 2x3",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
+ 0xcc, 0xdd, 0xee, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := Transpose(d.src)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
+
+func TestTransverse(t *testing.T) {
+ td := []struct {
+ desc string
+ src image.Image
+ want *image.NRGBA
+ }{
+ {
+ "Transverse 2x3",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 1, 2),
+ Stride: 2 * 4,
+ Pix: []uint8{
+ 0x00, 0x11, 0x22, 0x33, 0xcc, 0xdd, 0xee, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xcc, 0xdd, 0xee, 0xff,
+ 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x11, 0x22, 0x33,
+ },
+ },
+ },
+ }
+ for _, d := range td {
+ got := Transverse(d.src)
+ want := d.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: %#v", d.desc, got)
+ }
+ }
+}
diff --git a/vendor/github.com/disintegration/imaging/utils_test.go b/vendor/github.com/disintegration/imaging/utils_test.go
new file mode 100644
index 000000000..99aa8c82f
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/utils_test.go
@@ -0,0 +1,81 @@
+package imaging
+
+import (
+ "runtime"
+ "testing"
+)
+
+func testParallelN(enabled bool, n, procs int) bool {
+ data := make([]bool, n)
+ before := runtime.GOMAXPROCS(0)
+ runtime.GOMAXPROCS(procs)
+ parallel(n, func(start, end int) {
+ for i := start; i < end; i++ {
+ data[i] = true
+ }
+ })
+ for i := 0; i < n; i++ {
+ if data[i] != true {
+ return false
+ }
+ }
+ runtime.GOMAXPROCS(before)
+ return true
+}
+
+func TestParallel(t *testing.T) {
+ for _, e := range []bool{true, false} {
+ for _, n := range []int{1, 10, 100, 1000} {
+ for _, p := range []int{1, 2, 4, 8, 16, 100} {
+ if testParallelN(e, n, p) != true {
+ t.Errorf("test [parallel %v %d %d] failed", e, n, p)
+ }
+ }
+ }
+ }
+}
+
+func TestClamp(t *testing.T) {
+ td := []struct {
+ f float64
+ u uint8
+ }{
+ {0, 0},
+ {255, 255},
+ {128, 128},
+ {0.49, 0},
+ {0.50, 1},
+ {254.9, 255},
+ {254.0, 254},
+ {256, 255},
+ {2500, 255},
+ {-10, 0},
+ {127.6, 128},
+ }
+
+ for _, d := range td {
+ if clamp(d.f) != d.u {
+ t.Errorf("test [clamp %v %v] failed: %v", d.f, d.u, clamp(d.f))
+ }
+ }
+}
+
+func TestClampint32(t *testing.T) {
+ td := []struct {
+ i int32
+ u uint8
+ }{
+ {0, 0},
+ {255, 255},
+ {128, 128},
+ {256, 255},
+ {2500, 255},
+ {-10, 0},
+ }
+
+ for _, d := range td {
+ if clampint32(d.i) != d.u {
+ t.Errorf("test [clampint32 %v %v] failed: %v", d.i, d.u, clampint32(d.i))
+ }
+ }
+}