mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-09 07:28:44 -07:00
Auto-width and height calculations now round instead of floor.
This commit is contained in:
parent
1278491e23
commit
552db7d3b5
2 changed files with 31 additions and 2 deletions
|
|
@ -1,6 +1,9 @@
|
|||
package bimg
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
"image/jpeg"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
|
|
@ -112,6 +115,24 @@ func TestResizeCustomSizes(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestResizePrecision(t *testing.T) {
|
||||
// see https://github.com/h2non/bimg/issues/99
|
||||
img := image.NewGray16(image.Rect(0, 0, 1920, 1080))
|
||||
input := &bytes.Buffer{}
|
||||
jpeg.Encode(input, img, nil)
|
||||
|
||||
opts := Options{Width: 300}
|
||||
newImg, err := Resize(input.Bytes(), opts)
|
||||
if err != nil {
|
||||
t.Fatalf("Resize(imgData, %#v) error: %#v", opts, err)
|
||||
}
|
||||
|
||||
size, _ := Size(newImg)
|
||||
if size.Width != opts.Width {
|
||||
t.Fatalf("Invalid width: %d", size.Width)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRotate(t *testing.T) {
|
||||
options := Options{Width: 800, Height: 600, Rotate: 270, Crop: true}
|
||||
buf, _ := Read("fixtures/test.jpg")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue