|
|
|
@ -32,14 +32,6 @@ func Resize(buf []byte, o Options) ([]byte, error) {
|
|
|
|
|
|
|
|
|
|
|
|
debug("Options: %#v", o)
|
|
|
|
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)
|
|
|
|
inWidth := int(image.Xsize)
|
|
|
|
inHeight := int(image.Ysize)
|
|
|
|
inHeight := int(image.Ysize)
|
|
|
|
|
|
|
|
|
|
|
|
@ -76,6 +68,12 @@ func Resize(buf []byte, o Options) ([]byte, error) {
|
|
|
|
residual = float64(shrink) / factor
|
|
|
|
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
|
|
|
|
// Zoom image, if necessary
|
|
|
|
image, err = zoomImage(image, o.Zoom)
|
|
|
|
image, err = zoomImage(image, o.Zoom)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
@ -104,12 +102,6 @@ func Resize(buf []byte, o Options) ([]byte, error) {
|
|
|
|
return nil, err
|
|
|
|
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
|
|
|
|
// Flatten image on a background, if necessary
|
|
|
|
image, err = imageFlatten(image, imageType, o)
|
|
|
|
image, err = imageFlatten(image, imageType, o)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
@ -266,7 +258,7 @@ func rotateAndFlipImage(image *C.VipsImage, o Options) (*C.VipsImage, error) {
|
|
|
|
if flip {
|
|
|
|
if flip {
|
|
|
|
o.Flip = flip
|
|
|
|
o.Flip = flip
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if rotation > D0 && o.Rotate == 0 {
|
|
|
|
if rotation > 0 && o.Rotate == 0 {
|
|
|
|
o.Rotate = rotation
|
|
|
|
o.Rotate = rotation
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|