mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-09 07:28:44 -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 {
|
type Sharpen struct {
|
||||||
Radius int
|
Radius int
|
||||||
X1 float64
|
X1 float64
|
||||||
Y2 float64
|
Y2 float64
|
||||||
Y3 float64
|
Y3 float64
|
||||||
M1 float64
|
M1 float64
|
||||||
M2 float64
|
M2 float64
|
||||||
}
|
}
|
||||||
|
|
||||||
// Supported image transformation options
|
// 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)
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
package bimg
|
package bimg
|
||||||
|
|
||||||
const Version = "0.1.22"
|
const Version = "0.1.23"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue