0
Fork 0
mirror of https://github.com/willnorris/imageproxy.git synced 2024-12-16 21:56:43 -05:00

fix ordering of flip and rotation transformations

Fixes #112
This commit is contained in:
Will Norris 2017-09-06 22:01:13 +00:00
parent 4b637567e3
commit 03d75816a0
2 changed files with 14 additions and 9 deletions

View file

@ -207,14 +207,6 @@ func transformImage(m image.Image, opt Options) image.Image {
}
}
// flip
if opt.FlipVertical {
m = imaging.FlipV(m)
}
if opt.FlipHorizontal {
m = imaging.FlipH(m)
}
// rotate
switch opt.Rotate {
case 90:
@ -225,5 +217,13 @@ func transformImage(m image.Image, opt Options) image.Image {
m = imaging.Rotate270(m)
}
// flip
if opt.FlipVertical {
m = imaging.FlipV(m)
}
if opt.FlipHorizontal {
m = imaging.FlipH(m)
}
return m
}

View file

@ -185,6 +185,11 @@ func TestTransformImage(t *testing.T) {
Options{FlipHorizontal: true, FlipVertical: true},
newImage(2, 2, yellow, blue, green, red),
},
{
ref,
Options{Rotate: 90, FlipHorizontal: true},
newImage(2, 2, yellow, green, blue, red),
},
// resizing
{ // can't resize larger than original image
@ -247,7 +252,7 @@ func TestTransformImage(t *testing.T) {
{
newImage(4, 2, red, red, blue, blue, red, red, blue, blue),
Options{Width: 2, Height: 1, Fit: true, FlipHorizontal: true, Rotate: 90},
newImage(1, 2, red, blue),
newImage(1, 2, blue, red),
},
// crop