(t *testing.T)
| 99 | } |
| 100 | |
| 101 | func TestProcessor(t *testing.T) { |
| 102 | v := NewProcessor(WithDebug(true)) |
| 103 | require.NoError(t, v.Startup(context.Background())) |
| 104 | t.Cleanup(func() { |
| 105 | stats := &vips.MemoryStats{} |
| 106 | vips.ReadVipsMemStats(stats) |
| 107 | fmt.Println(stats) |
| 108 | require.NoError(t, v.Shutdown(context.Background())) |
| 109 | }) |
| 110 | t.Run("vips basic", func(t *testing.T) { |
| 111 | var resultDir = filepath.Join(testDataDir, "golden") |
| 112 | doGoldenTests(t, resultDir, []test{ |
| 113 | {name: "png", path: "gopher-front.png"}, |
| 114 | {name: "jpeg", path: "fit-in/100x100/demo1.jpg"}, |
| 115 | {name: "webp", path: "fit-in/100x100/demo3.webp", arm64Golden: true}, |
| 116 | {name: "tiff", path: "fit-in/100x100/gopher.tiff"}, |
| 117 | {name: "avif", path: "fit-in/100x100/gopher-front.avif", checkTypeOnly: true}, |
| 118 | {name: "jxl", path: "fit-in/100x100/jxl-isobmff.jxl", checkTypeOnly: true}, |
| 119 | {name: "export gif", path: "filters:format(gif):quality(70)/gopher-front.png"}, |
| 120 | {name: "export webp", path: "filters:format(webp):quality(70)/gopher-front.png", arm64Golden: true}, |
| 121 | {name: "export tiff", path: "filters:format(tiff):quality(70)/gopher-front.png"}, |
| 122 | {name: "export jxl", path: "filters:format(jxl):quality(70)/gopher-front.png", checkTypeOnly: true}, |
| 123 | {name: "export avif", path: "filters:format(avif):quality(70)/gopher-front.png", checkTypeOnly: true}, |
| 124 | {name: "export heif", path: "filters:format(heif):quality(70)/gopher-front.png", checkTypeOnly: true}, |
| 125 | }, WithDebug(true), WithLogger(zap.NewExample())) |
| 126 | }) |
| 127 | t.Run("vips lossless filter", func(t *testing.T) { |
| 128 | var resultDir = filepath.Join(testDataDir, "golden") |
| 129 | doGoldenTests(t, resultDir, []test{ |
| 130 | {name: "lossless webp", path: "filters:format(webp):lossless()/gopher-front.png", arm64Golden: true}, |
| 131 | {name: "lossless webp with quality", path: "filters:format(webp):lossless():quality(60)/gopher-front.png", arm64Golden: true}, |
| 132 | {name: "lossless noop jpeg", path: "filters:format(jpeg):lossless():quality(70)/gopher-front.png"}, |
| 133 | {name: "lossless noop png", path: "filters:format(png):lossless()/gopher-front.png"}, |
| 134 | {name: "lossless skips max_bytes retry", path: "filters:format(webp):lossless():max_bytes(100)/gopher-front.png", arm64Golden: true}, |
| 135 | }, WithDebug(true), WithLogger(zap.NewExample())) |
| 136 | }) |
| 137 | t.Run("vips lossless webp round-trip", func(t *testing.T) { |
| 138 | src, err := vips.NewImageFromFile(filepath.Join(testDataDir, "gopher-front.png"), nil) |
| 139 | require.NoError(t, err) |
| 140 | defer src.Close() |
| 141 | |
| 142 | buf, err := v.export(src, vips.ImageTypeWebp, 0, 0, false, 0, false, true) |
| 143 | require.NoError(t, err) |
| 144 | |
| 145 | out, err := vips.NewImageFromBuffer(buf, nil) |
| 146 | require.NoError(t, err) |
| 147 | defer out.Close() |
| 148 | |
| 149 | require.Equal(t, src.Width(), out.Width(), "width must match") |
| 150 | require.Equal(t, src.Height(), out.Height(), "height must match") |
| 151 | require.Equal(t, src.Bands(), out.Bands(), "band count must match") |
| 152 | }) |
| 153 | t.Run("vips lossless round-trip pixel-exact", func(t *testing.T) { |
| 154 | src, err := vips.NewImageFromFile(filepath.Join(testDataDir, "gopher-front.png"), nil) |
| 155 | require.NoError(t, err) |
| 156 | defer src.Close() |
| 157 | |
| 158 | for _, f := range []struct { |
nothing calls this directly
no test coverage detected