mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-11 04:32:29 +02:00
Make filters low-level
This commit is contained in:
@@ -2,7 +2,6 @@ package processing
|
||||
|
||||
import (
|
||||
"github.com/imgproxy/imgproxy/v3/imagedata"
|
||||
"github.com/imgproxy/imgproxy/v3/imath"
|
||||
"github.com/imgproxy/imgproxy/v3/options"
|
||||
"github.com/imgproxy/imgproxy/v3/vips"
|
||||
)
|
||||
@@ -20,35 +19,7 @@ func applyFilters(pctx *pipelineContext, img *vips.Image, po *options.Processing
|
||||
return err
|
||||
}
|
||||
|
||||
// When image has alpha, we need to premultiply it to get rid of black edges
|
||||
if err := img.Premultiply(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if po.Blur > 0 {
|
||||
if err := img.Blur(po.Blur); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if po.Sharpen > 0 {
|
||||
if err := img.Sharpen(po.Sharpen); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if po.Pixelate > 1 {
|
||||
pixels := imath.Min(po.Pixelate, imath.Min(img.Width(), img.Height()))
|
||||
if err := img.Pixelate(pixels); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := img.Unpremultiply(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := img.CastUchar(); err != nil {
|
||||
if err := img.ApplyFilters(po.Blur, po.Sharpen, po.Pixelate); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user