mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-07 21:48:13 -08:00
Merge branch 'master' into master
This commit is contained in:
commit
599dc0ba03
9 changed files with 82 additions and 20 deletions
12
resizer.go
12
resizer.go
|
|
@ -12,6 +12,10 @@ import (
|
|||
"math"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrExtractAreaParamsRequired = errors.New("extract area width/height params are required")
|
||||
)
|
||||
|
||||
// resizer is used to transform a given image as byte buffer
|
||||
// with the passed options.
|
||||
func resizer(buf []byte, o Options) ([]byte, error) {
|
||||
|
|
@ -274,7 +278,7 @@ func extractOrEmbedImage(image *C.VipsImage, o Options) (*C.VipsImage, error) {
|
|||
break
|
||||
case o.Top != 0 || o.Left != 0 || o.AreaWidth != 0 || o.AreaHeight != 0:
|
||||
if o.AreaWidth == 0 {
|
||||
o.AreaHeight = o.Width
|
||||
o.AreaWidth = o.Width
|
||||
}
|
||||
if o.AreaHeight == 0 {
|
||||
o.AreaHeight = o.Height
|
||||
|
|
@ -444,7 +448,11 @@ func imageCalculations(o *Options, inWidth, inHeight int) float64 {
|
|||
switch {
|
||||
// Fixed width and height
|
||||
case o.Width > 0 && o.Height > 0:
|
||||
factor = math.Min(xfactor, yfactor)
|
||||
if o.Crop {
|
||||
factor = math.Min(xfactor, yfactor)
|
||||
} else {
|
||||
factor = math.Max(xfactor, yfactor)
|
||||
}
|
||||
// Fixed width, auto height
|
||||
case o.Width > 0:
|
||||
if o.Crop {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue