mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-16 02:45:54 -07:00
refactor(resize): clone options by value
This commit is contained in:
parent
82f17f66d5
commit
13ef72dc03
1 changed files with 4 additions and 3 deletions
|
|
@ -23,8 +23,8 @@ func Resize(buf []byte, o Options) ([]byte, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define default options
|
// Clone and define default options
|
||||||
applyDefaults(&o, imageType)
|
o = applyDefaults(o, imageType)
|
||||||
|
|
||||||
if IsTypeSupported(o.Type) == false {
|
if IsTypeSupported(o.Type) == false {
|
||||||
return nil, errors.New("Unsupported image output type")
|
return nil, errors.New("Unsupported image output type")
|
||||||
|
|
@ -121,7 +121,7 @@ func Resize(buf []byte, o Options) ([]byte, error) {
|
||||||
return vipsSave(image, saveOptions)
|
return vipsSave(image, saveOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyDefaults(o *Options, imageType ImageType) {
|
func applyDefaults(o Options, imageType ImageType) Options {
|
||||||
if o.Quality == 0 {
|
if o.Quality == 0 {
|
||||||
o.Quality = QUALITY
|
o.Quality = QUALITY
|
||||||
}
|
}
|
||||||
|
|
@ -134,6 +134,7 @@ func applyDefaults(o *Options, imageType ImageType) {
|
||||||
if o.Interpretation == 0 {
|
if o.Interpretation == 0 {
|
||||||
o.Interpretation = INTERPRETATION_sRGB
|
o.Interpretation = INTERPRETATION_sRGB
|
||||||
}
|
}
|
||||||
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
func normalizeOperation(o *Options, inWidth, inHeight int) {
|
func normalizeOperation(o *Options, inWidth, inHeight int) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue