MCPcopy
hub / github.com/h2non/bimg / TestEmbedExtendColor

Function TestEmbedExtendColor

resizer_test.go:265–280  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

263}
264
265func TestEmbedExtendColor(t *testing.T) {
266 options := Options{Width: 400, Height: 600, Crop: false, Embed: true, Extend: ExtendWhite, Background: Color{255, 20, 10}}
267 buf, _ := Read("testdata/test_issue.jpg")
268
269 newImg, err := Resize(buf, options)
270 if err != nil {
271 t.Errorf("Resize(imgData, %#v) error: %#v", options, err)
272 }
273
274 size, _ := Size(newImg)
275 if size.Height != options.Height || size.Width != options.Width {
276 t.Fatalf("Invalid image size: %dx%d", size.Width, size.Height)
277 }
278
279 Write("testdata/test_extend_white_out.jpg", newImg)
280}
281
282func TestEmbedExtendWithCustomColor(t *testing.T) {
283 options := Options{Width: 400, Height: 600, Crop: false, Embed: true, Extend: 5, Background: Color{255, 20, 10}}

Callers

nothing calls this directly

Calls 4

ReadFunction · 0.85
SizeFunction · 0.85
WriteFunction · 0.85
ResizeFunction · 0.70

Tested by

no test coverage detected