2021-04-26 17:52:50 +06:00
|
|
|
package processing
|
|
|
|
|
|
|
|
import (
|
2021-09-30 20:23:30 +06:00
|
|
|
"github.com/imgproxy/imgproxy/v3/imagedata"
|
|
|
|
"github.com/imgproxy/imgproxy/v3/options"
|
|
|
|
"github.com/imgproxy/imgproxy/v3/vips"
|
2021-04-26 17:52:50 +06:00
|
|
|
)
|
|
|
|
|
|
|
|
func applyFilters(pctx *pipelineContext, img *vips.Image, po *options.ProcessingOptions, imgdata *imagedata.ImageData) error {
|
2021-05-17 19:42:31 +06:00
|
|
|
if po.Blur == 0 && po.Sharpen == 0 && po.Pixelate <= 1 {
|
2021-04-26 17:52:50 +06:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-06-23 17:23:04 +06:00
|
|
|
if err := img.CopyMemory(); err != nil {
|
2021-04-26 17:52:50 +06:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := img.RgbColourspace(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-07-28 15:32:36 +06:00
|
|
|
if err := img.ApplyFilters(po.Blur, po.Sharpen, po.Pixelate); err != nil {
|
2021-04-26 17:52:50 +06:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-06-23 17:23:04 +06:00
|
|
|
return img.CopyMemory()
|
2021-04-26 17:52:50 +06:00
|
|
|
}
|