diff --git a/options.go b/options.go index 67af96d..9526914 100644 --- a/options.go +++ b/options.go @@ -91,6 +91,11 @@ type Watermark struct { Background Color } +type GaussianBlur struct { + Sigma float64 + MinAmpl float64 +} + type Options struct { Height int Width int @@ -117,4 +122,5 @@ type Options struct { Type ImageType Interpolator Interpolator Interpretation Interpretation + GaussianBlur GaussianBlur } diff --git a/vips.go b/vips.go index 7734057..fc8bc7c 100644 --- a/vips.go +++ b/vips.go @@ -432,3 +432,14 @@ func boolToInt(b bool) int { } return 0 } + +func vipsGaussianBlur(image *C.VipsImage, o GaussianBlur) (*C.VipsImage, error) { + var out *C.VipsImage + defer C.g_object_unref(C.gpointer(image)) + + err := C.vips__gaussblur(image, &out, C.double(o.Sigma), C.double(o.MinAmpl)) + if err != 0 { + return nil, catchVipsError() + } + return out, nil +} diff --git a/vips.h b/vips.h index 428e994..ee0be0f 100644 --- a/vips.h +++ b/vips.h @@ -16,6 +16,9 @@ */ #if (VIPS_MAJOR_VERSION == 7 && VIPS_MINOR_VERSION < 41) +/* we need math.h for ceil() in vips__gaussblur */ +#include + #define VIPS_ANGLE_D0 VIPS_ANGLE_0 #define VIPS_ANGLE_D90 VIPS_ANGLE_90 #define VIPS_ANGLE_D180 VIPS_ANGLE_180 @@ -321,3 +324,12 @@ vips_watermark(VipsImage *in, VipsImage **out, WatermarkTextOptions *to, Waterma g_object_unref(base); return 0; } + +int +vips__gaussblur(VipsImage *in, VipsImage **out, double sigma, double min_ampl) { +#if (VIPS_MAJOR_VERSION == 7 && VIPS_MINOR_VERSION < 41) + return vips_gaussblur(in, out, ceil(sigma), NULL); +#else + return vips_gaussblur(in, out, sigma, NULL, "min_ampl", min_ampl); +#endif +}