#!/usr/bin/env python
#
# ==============================================================================
# GreenScreen.py (c) Julian Kunkel 2018
# ==============================================================================
#
# Green Screen remover
#
# ==============================================================================
#
# 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, version 3 of the License.
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
#
# ==============================================================================
from gimpfu import *
from string import *
def GreenScreen(img,drw):
pdb.gimp_image_undo_group_start(img)
layn = pdb.gimp_layer_new_from_visible(img, img, 'mask')
pdb.gimp_image_insert_layer(img, layn, None, -1)
layn = pdb.gimp_layer_new_from_visible(img, img, 'orig')
pdb.gimp_image_insert_layer(img, layn, None, -1)
pdb.gimp_selection_clear(img)
drw = img.layers[0] # pdb.gimp_image_active_drawable(img)
pdb.gimp_hue_saturation (drw,4,0,0,-100)
pdb.gimp_hue_saturation (drw,3,0,0,-100)
pdb.gimp_layer_set_mode(drw, 6)
pdb.gimp_image_merge_down (img, drw, 0)
pdb.gimp_hue_saturation (img.layers[1],4,0,0,-100)
pdb.gimp_hue_saturation (img.layers[1],3,0,0,-100)
pdb.gimp_by_color_select (img.layers[0], (0,0,0), 15, CHANNEL_OP_REPLACE, True, False,0,True)
pdb.gimp_image_remove_layer(img, img.layers[0])
pdb.gimp_layer_add_alpha(img.layers[0])
pdb.gimp_selection_invert(img)
pdb.gimp_selection_grow(img, 3)
pdb.gimp_selection_feather(img, 50)
pdb.gimp_image_undo_group_end(img)
register(
"plug-in-green-screen",
"",
"Cleanup green screen",
"Julian Kunkel",
"public domain",
"2009",
"/Select/GreenScreen",
"RGB*, GRAY*",
[],
[],
GreenScreen)
main()