Add tool to remove transparent pixels from GCI
This commit is contained in:
parent
b20e00b5ce
commit
9a83fb65c4
3 changed files with 54 additions and 0 deletions
|
@ -9,6 +9,12 @@ also belong here. Other utils are in utils/.
|
|||
A program for converting campaigns to use trackplacer-format journey files.
|
||||
All mainline campaigns have already been converted; this is for lifting UMC.
|
||||
|
||||
=== rmtrans ===
|
||||
|
||||
Remove nearly transparent pixels from images using GIMP. It currently affects
|
||||
only one image at a time. Batch processing is available within GIMP, but it
|
||||
would be useful to expand this to skip files where the pixels did not change.
|
||||
|
||||
=== trackplacer ===
|
||||
|
||||
A visual editor for journey tracks, the icon sequences that appear on
|
||||
|
|
7
data/tools/rmtrans/README
Normal file
7
data/tools/rmtrans/README
Normal file
|
@ -0,0 +1,7 @@
|
|||
This is a GIMP script, written in python.
|
||||
See the following address to install the script:
|
||||
https://en.wikibooks.org/wiki/GIMP/Installing_Plugins#Copying_the_plugin_to_the_GIMP_plugin_directory
|
||||
|
||||
When installed, the script will be listed under the "Colors" menu.
|
||||
|
||||
It requires a relatively recent version of GIMP. 2.6 is too old.
|
41
data/tools/rmtrans/rmtrans.py
Executable file
41
data/tools/rmtrans/rmtrans.py
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from gimpfu import *
|
||||
|
||||
def rmtrans(img,tdrawable):
|
||||
pdb.gimp_image_undo_group_start(img)
|
||||
if pdb.gimp_selection_is_empty(img):
|
||||
pdb.gimp_selection_all(img)
|
||||
selection = pdb.gimp_selection_save(img)
|
||||
pdb.gimp_selection_none(img)
|
||||
alpha,temp,temp,temp = pdb.plug_in_decompose(img,tdrawable,"Alpha",1) # get alpha channel
|
||||
alpha = pdb.gimp_image_get_active_layer(alpha) # turn it into a layer
|
||||
pdb.gimp_edit_copy(alpha)
|
||||
pdb.gimp_floating_sel_to_layer(pdb.gimp_edit_paste(tdrawable,TRUE))
|
||||
alpha = pdb.gimp_image_get_active_layer(img) # move alpha layer into image (copy-paste)
|
||||
pdb.gimp_context_set_antialias(False)
|
||||
pdb.gimp_context_set_sample_threshold(0.0) # configuration for color selection
|
||||
for i in xrange(10):
|
||||
pdb.gimp_image_select_color(img,CHANNEL_OP_REPLACE,alpha,(i,i,i)) # select alpha values <= 10
|
||||
pdb.gimp_image_select_item(img,CHANNEL_OP_INTERSECT,selection) # bound it to the previously selected area (before plugin execution)
|
||||
if not(pdb.gimp_selection_is_empty(img)):
|
||||
pdb.gimp_edit_clear(tdrawable) # and clear it
|
||||
print(alpha)
|
||||
pdb.gimp_image_remove_layer(img,alpha)
|
||||
pdb.gimp_selection_none(img)
|
||||
pdb.gimp_image_undo_group_end(img)
|
||||
|
||||
register(
|
||||
"python_fu_rmtrans",
|
||||
"Remove all pixels under a given alpha threshold.",
|
||||
"Remove all pixels under a given alpha threshold.",
|
||||
"Samuel Kim",
|
||||
"Samuel Kim",
|
||||
"2012",
|
||||
"<Image>/Colors/Remove almost-transparent pixels",
|
||||
"*",
|
||||
[],
|
||||
[],
|
||||
rmtrans)
|
||||
|
||||
main()
|
Loading…
Add table
Reference in a new issue