mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-08 15:08:16 -07:00
commit
6ca41bbafc
3 changed files with 14 additions and 22 deletions
12
options.go
12
options.go
|
|
@ -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
|
||||
|
|
|
|||
22
resize.go
22
resize.go
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
package bimg
|
||||
|
||||
const Version = "0.1.22"
|
||||
const Version = "0.1.23"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue