fix(rotation)

This commit is contained in:
Tomas Aparicio 2016-02-05 15:19:32 +00:00
parent a7706b6033
commit cc455d8f48
2 changed files with 13 additions and 21 deletions

View file

@ -101,12 +101,12 @@ type GaussianBlur struct {
}
type Sharpen struct {
Radius int
X1 float64
Y2 float64
Y3 float64
M1 float64
M2 float64
Radius int
X1 float64
Y2 float64
Y3 float64
M1 float64
M2 float64
}
// Supported image transformation options

View file

@ -32,14 +32,6 @@ func Resize(buf []byte, o Options) ([]byte, error) {
debug("Options: %#v", o)
// Initial image auto rotate / flip for proper transformation calculus
if o.Rotate == 0 {
image, err = rotateAndFlipImage(image, o)
if err != nil {
return nil, err
}
}
inWidth := int(image.Xsize)
inHeight := int(image.Ysize)
@ -76,6 +68,12 @@ func Resize(buf []byte, o Options) ([]byte, error) {
residual = float64(shrink) / factor
}
// Explicit or auto rotate image based on EXIF header
image, err = rotateAndFlipImage(image, o)
if err != nil {
return nil, err
}
// Zoom image, if necessary
image, err = zoomImage(image, o.Zoom)
if err != nil {
@ -104,12 +102,6 @@ func Resize(buf []byte, o Options) ([]byte, error) {
return nil, err
}
// Transform to original rotation, if necessary
image, err = rotateAndFlipImage(image, o)
if err != nil {
return nil, err
}
// Flatten image on a background, if necessary
image, err = imageFlatten(image, imageType, o)
if err != nil {
@ -266,7 +258,7 @@ func rotateAndFlipImage(image *C.VipsImage, o Options) (*C.VipsImage, error) {
if flip {
o.Flip = flip
}
if rotation > D0 && o.Rotate == 0 {
if rotation > 0 && o.Rotate == 0 {
o.Rotate = rotation
}
}