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

Function TestRotate

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

Source from the content-addressed store, hash-verified

180}
181
182func TestRotate(t *testing.T) {
183 options := Options{Width: 800, Height: 600, Rotate: 270, Crop: true}
184 buf, _ := Read("testdata/test.jpg")
185
186 newImg, err := Resize(buf, options)
187 if err != nil {
188 t.Errorf("Resize(imgData, %#v) error: %#v", options, err)
189 }
190
191 if DetermineImageType(newImg) != JPEG {
192 t.Error("Image is not jpeg")
193 }
194
195 size, _ := Size(newImg)
196 if size.Width != options.Width || size.Height != options.Height {
197 t.Errorf("Invalid image size: %dx%d", size.Width, size.Height)
198 }
199
200 Write("testdata/test_rotate_out.jpg", newImg)
201}
202
203func TestInvalidRotateDegrees(t *testing.T) {
204 options := Options{Width: 800, Height: 600, Rotate: 111, Crop: true}

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected