refactor(resize): clone options by value

master
Tomas Aparicio 10 years ago
parent 82f17f66d5
commit 13ef72dc03

@ -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…
Cancel
Save