fix(resize): support rotate

master
Tomas Aparicio 11 years ago
parent 40dd19fa6a
commit 812532b615

@ -34,6 +34,8 @@ func Resize(buf []byte, o Options) ([]byte, error) {
return nil, errors.New("Unsupported image output type") return nil, errors.New("Unsupported image output type")
} }
debug("Options: %#v", o)
// get WxH // get WxH
inWidth := int(image.Xsize) inWidth := int(image.Xsize)
inHeight := int(image.Ysize) inHeight := int(image.Ysize)
@ -100,13 +102,15 @@ func Resize(buf []byte, o Options) ([]byte, error) {
return nil, err return nil, err
} }
if o.Rotate == 0 {
rotation, flip := calculateRotationAndFlip(image, o.Rotate) rotation, flip := calculateRotationAndFlip(image, o.Rotate)
if flip { if flip {
o.Flip = HORIZONTAL o.Flip = HORIZONTAL
} }
if rotation != D0 { if rotation > D0 {
o.Rotate = rotation o.Rotate = rotation
} }
}
if o.Rotate > 0 { if o.Rotate > 0 {
image, err = vipsRotate(image, getAngle(o.Rotate)) image, err = vipsRotate(image, getAngle(o.Rotate))

Loading…
Cancel
Save