MCPcopy
hub / github.com/willnorris/imageproxy / TestTransform_EXIF_Rotate

Function TestTransform_EXIF_Rotate

transform_test.go:216–241  ·  view source on GitHub ↗

Test that EXIF orientation and any additional transforms don't conflict. This is tested with orientation=7, which involves both a rotation and a flip, combined with an additional rotation transform.

(t *testing.T)

Source from the content-addressed store, hash-verified

214// This is tested with orientation=7, which involves both a rotation and a
215// flip, combined with an additional rotation transform.
216func TestTransform_EXIF_Rotate(t *testing.T) {
217 // base64-encoded TIF image (2x2 yellow green blue red) with EXIF
218 // orientation=7. When orientation applied, displays as (2x2 red green
219 // blue yellow).
220 src := "SUkqAAgAAAAOAAABAwABAAAAAgAAAAEBAwABAAAAAgAAAAIBAwAEAAAAtgAAAAMBAwABAAAACAAAAAYBAwABAAAAAgAAABEBBAABAAAAzgAAABIBAwABAAAABwAAABUBAwABAAAABAAAABYBAwABAAAAAgAAABcBBAABAAAAFgAAABoBBQABAAAAvgAAABsBBQABAAAAxgAAACgBAwABAAAAAgAAAFIBAwABAAAAAgAAAAAAAAAIAAgACAAIAEgAAAABAAAASAAAAAEAAAB4nPr/nwECGf7/BxGAAAAA//9PwAj4"
221
222 in, err := base64.StdEncoding.DecodeString(src)
223 if err != nil {
224 t.Errorf("error decoding source: %v", err)
225 }
226 out, err := Transform(in, Options{Rotate: 90, Format: "tiff"})
227 if err != nil {
228 t.Errorf("Transform(%q) returned error: %v", src, err)
229 }
230 d, _, err := image.Decode(bytes.NewReader(out))
231 if err != nil {
232 t.Errorf("error decoding transformed image: %v", err)
233 }
234
235 // construct new image with same colors as decoded image for easy comparison
236 got := newImage(2, 2, d.At(0, 0), d.At(1, 0), d.At(0, 1), d.At(1, 1))
237 want := newImage(2, 2, green, yellow, red, blue)
238 if !reflect.DeepEqual(got, want) {
239 t.Errorf("Transform(%v) returned image %#v, want %#v", src, got, want)
240 }
241}
242
243func TestTransformImage(t *testing.T) {
244 // ref is a 2x2 reference image containing four colors

Callers

nothing calls this directly

Calls 2

TransformFunction · 0.85
newImageFunction · 0.85

Tested by

no test coverage detected