|
|
|
@ -82,10 +82,8 @@ func Resize(buf []byte, o Options) ([]byte, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Transform image if necessary
|
|
|
|
// Transform image if necessary
|
|
|
|
debug(">>>>> Resolution %dx%d -> %dx%d", o.Width, o.Height, inWidth, inHeight)
|
|
|
|
shouldTransform := o.Width != inWidth || o.Height != inHeight || o.AreaWidth > 0 || o.AreaHeight > 0
|
|
|
|
|
|
|
|
if shouldTransform {
|
|
|
|
shouldExtract := o.Width != inWidth || o.Height != inHeight || o.AreaWidth > 0 || o.AreaHeight > 0
|
|
|
|
|
|
|
|
if shouldExtract {
|
|
|
|
|
|
|
|
// Use vips_shrink with the integral reduction
|
|
|
|
// Use vips_shrink with the integral reduction
|
|
|
|
if shrink > 1 {
|
|
|
|
if shrink > 1 {
|
|
|
|
image, residual, err = shrinkImage(image, o, residual, shrink)
|
|
|
|
image, residual, err = shrinkImage(image, o, residual, shrink)
|
|
|
|
@ -100,8 +98,8 @@ func Resize(buf []byte, o Options) ([]byte, error) {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
debug("factor: %v, shrink: %v, residual: %v", factor, shrink, residual)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
debug("Transform image: factor=%v, shrink=%v, residual=%v", factor, shrink, residual)
|
|
|
|
// Extract area from image
|
|
|
|
// Extract area from image
|
|
|
|
image, err = extractImage(image, o)
|
|
|
|
image, err = extractImage(image, o)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
|