;;
;;   File        : gmic_shell.scm
;;   
;;               ( Scheme script for GIMP )
;;   
;;   based on gmic_shell.scm script taken from David Tschumperlé


(define	(my-img-shell img drawable)

  ;; Start undo group.
  (gimp-image-undo-group-start img)

  (let* (
         (copy-layer (car (gimp-layer-copy drawable TRUE)))
        )

    ;; Add a copy of the layer to the image.
    (gimp-image-insert-layer img copy-layer 0 -1)

    ;;put your gmic commands in the following
;    (plug-in-gmic-qt 1 img drawable 1 0 "-v -99 -fx_stencilbw 10,10,0,0,0") ; example

    (plug-in-gauss-rle2 1 img copy-layer 25 25)             ; Gaussian Blur RLE2 with radis 25x25
    (gimp-invert copy-layer)                                ; Color inversion
    (gimp-desaturate-full copy-layer DESATURATE-LUMINOSITY) ; Color desaturation
    (gimp-layer-set-mode copy-layer OVERLAY-MODE)           ; Layer mode to OVERLAY

    (gimp-image-flatten img)
    
    )

  ;; Flush display.
  (gimp-displays-flush)

  ;; End undo group.
  (gimp-image-undo-group-end img)
  )

(script-fu-register "my-img-shell"
                    _"<Image>/Filters/My IMG shell..."
                    ""
                    ""
                    ""
                    "2017"
                    "*"
                    SF-IMAGE		"Image"		1
                    SF-DRAWABLE         "Drawable"      1
                    )
