mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-08 23:18:19 -07:00
fix(resize): auto rotate image before resize calculus
This commit is contained in:
parent
da1108f1ad
commit
edeb809cc1
3 changed files with 50 additions and 20 deletions
|
|
@ -113,7 +113,7 @@ func TestResizeCustomSizes(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRotate(t *testing.T) {
|
||||
options := Options{Width: 800, Height: 600, Rotate: 270}
|
||||
options := Options{Width: 800, Height: 600, Rotate: 270, Crop: true}
|
||||
buf, _ := Read("fixtures/test.jpg")
|
||||
|
||||
newImg, err := Resize(buf, options)
|
||||
|
|
@ -122,19 +122,19 @@ func TestRotate(t *testing.T) {
|
|||
}
|
||||
|
||||
if DetermineImageType(newImg) != JPEG {
|
||||
t.Fatal("Image is not jpeg")
|
||||
t.Error("Image is not jpeg")
|
||||
}
|
||||
|
||||
size, _ := Size(newImg)
|
||||
if size.Height != options.Width {
|
||||
t.Fatalf("Invalid image size: %dx%d", size.Width, size.Height)
|
||||
if size.Width != options.Width || size.Height != options.Height {
|
||||
t.Errorf("Invalid image size: %dx%d", size.Width, size.Height)
|
||||
}
|
||||
|
||||
Write("fixtures/test_rotate_out.jpg", newImg)
|
||||
}
|
||||
|
||||
func TestInvalidRotate(t *testing.T) {
|
||||
options := Options{Width: 800, Height: 600, Rotate: 111}
|
||||
func TestInvalidRotateDegrees(t *testing.T) {
|
||||
options := Options{Width: 800, Height: 600, Rotate: 111, Crop: true}
|
||||
buf, _ := Read("fixtures/test.jpg")
|
||||
|
||||
newImg, err := Resize(buf, options)
|
||||
|
|
@ -143,15 +143,15 @@ func TestInvalidRotate(t *testing.T) {
|
|||
}
|
||||
|
||||
if DetermineImageType(newImg) != JPEG {
|
||||
t.Fatal("Image is not jpeg")
|
||||
t.Errorf("Image is not jpeg")
|
||||
}
|
||||
|
||||
size, _ := Size(newImg)
|
||||
if size.Height != options.Width {
|
||||
t.Fatalf("Invalid image size: %dx%d", size.Width, size.Height)
|
||||
if size.Width != options.Width || size.Height != options.Height {
|
||||
t.Errorf("Invalid image size: %dx%d", size.Width, size.Height)
|
||||
}
|
||||
|
||||
Write("fixtures/test_invalid_rotate_out.jpg", newImg)
|
||||
Write("fixtures/test_rotate_invalid_out.jpg", newImg)
|
||||
}
|
||||
|
||||
func TestCorruptedImage(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue