# p0 - gamma 0.1 to 10 (1.5)
# p1 - radius 0 to $width (15)
# p2 - intensity 0 to 100 (25)
# p3 - negate (FALSE)

&rfx_sendmsg (
  qq{
    (let* ((input-file (string-append "$curtmpdir" DIR-SEPARATOR "$in"))
           (image (car (gimp-file-load RUN-NONINTERACTIVE input-file input-file)))
           (layer (car (gimp-image-get-active-layer image)))
           (blur-layer (car (gimp-layer-copy layer TRUE)))
           (intensity-layer (car (gimp-layer-copy layer TRUE)))
           (mask 0)
           )
      (gimp-image-undo-disable image)
      (gimp-image-add-layer image blur-layer 1)
      (gimp-image-add-layer image intensity-layer 0)
      (set! mask (car (gimp-layer-create-mask intensity-layer ADD-WHITE-MASK)))
      (gimp-layer-add-mask intensity-layer mask)
      (gimp-context-set-foreground (make-list 3 (/ (* (abs (- 100 $p2)) 255) 100)))
      (gimp-drawable-fill mask FOREGROUND-FILL)
      (gimp-layer-set-mode layer (if (zero? $p3) 
                                        OVERLAY-MODE 
                                        MULTIPLY-MODE ))
      (plug-in-gauss-iir2 RUN-NONINTERACTIVE image blur-layer $p1 $p1)
      (gimp-levels layer 0 0 255 $p0 0 255)
      (gimp-image-merge-visible-layers image CLIP-TO-IMAGE)
      
      (rfx-save-frame image "$out") )
    }
  );

