;;; Plugin  : reptile skin
;;; Author  : Rod Detmer
;;; Date    : October 29th 2016
;;; Revision: v-01
;;;                
;;; Version : v-01
;;; Latest version at: http://www.gimpchat.com
;;; Required : Gimp 2.8 or later
;;;
;;; Description:Removes bg color from Hemera Photo Objects png images 
;;; adds alpha channel-selects by color-grows selection by 1 pixel-color to alpha bg color
;;; -----------------------------------------------------------------------------
;;; Change Log:
;;; Version-1.0
;;;
; Information can be found at http://www.gimpchat.com
;
; License: GPLv3
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; To view a copy of the GNU General Public License
; visit: http://www.gnu.org/licenses/gpl.html

(define (script-fu-remove-hemera-image-bg-color image drawable color pixelGrowth)
(gimp-image-undo-group-start image)

  ; save user settings
  (gimp-context-push)
 
  ; begin
  
  ;add alpha channel
  (gimp-layer-add-alpha drawable)
  (gimp-image-select-color image 2 drawable color)
  (gimp-selection-grow image pixelGrowth)
  (plug-in-colortoalpha RUN-NONINTERACTIVE image drawable color)
  (gimp-selection-none image)
  
          ; end
  (gimp-selection-none image)    
  ; display new image and return user settings
  (gimp-context-pop)
  (gimp-image-undo-group-end image)
  (gimp-displays-flush image) 
)  
  (script-fu-register
"script-fu-remove-hemera-image-bg-color"
"<Image>/Rod/Remove Photo Object BG Color"
"Remove Photo Object BG Color"
"Rod Detmer"
"Rod Detmer"
"October 2016"
"RGB* GRAY*"
SF-IMAGE       "The Image" 0
SF-DRAWABLE    "The Drawable" 0
SF-COLOR "Remove color"       '(0 0 191) 
SF-ADJUSTMENT "Grow Selection by How Much?" '(3 0 500 1 10 0 SF-SLIDER)                      
)  
  