-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
4,326 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
from gimpfu import * | ||
import re | ||
import codecs | ||
selectionCase = ("none","lowercase", "UPPERCASE", "Capitalize", "Sentence","Title") | ||
def py_group_chfont(img, tdraw, bfont, font, bcolorfont, colorFont, bsize,size, bscale,scale,bletterspacing,letter_spacing,blinespacing,line_spacing,cremovestyle,achangeCase,allgroup,rec): | ||
### nested function to parse group layers ### | ||
def dogroup(group): | ||
ll = group.layers | ||
for layer in ll: | ||
### recursion for nested groups ### | ||
pdb.gimp_progress_pulse() | ||
if (type(layer) == gimp.GroupLayer): | ||
if rec: | ||
dogroup(layer) | ||
### actual action ### | ||
else: | ||
if pdb.gimp_item_is_text_layer(layer): | ||
if bfont: | ||
pdb.gimp_text_layer_set_font(layer, font) | ||
if bcolorfont: | ||
pdb.gimp_text_layer_set_color(layer, colorFont) | ||
if bsize: | ||
pdb.gimp_text_layer_set_font_size(layer, size, 0) | ||
if bscale: | ||
font_size, unit = pdb.gimp_text_layer_get_font_size(layer) | ||
pdb.gimp_text_layer_set_font_size(layer, font_size*scale, 0) | ||
if bletterspacing: | ||
pdb.gimp_text_layer_set_letter_spacing(layer, letter_spacing) | ||
if blinespacing: | ||
pdb.gimp_text_layer_set_line_spacing(layer, line_spacing) | ||
if cremovestyle: | ||
text=pdb.gimp_text_layer_get_markup(layer) | ||
if text is not None: | ||
text=re.sub("<.*?>", "",text) | ||
pdb.gimp_text_layer_set_text(layer,text) | ||
|
||
if achangeCase>0: | ||
text=pdb.gimp_text_layer_get_text(layer) | ||
if text is not None: | ||
text=changeCaseText(text.decode("utf-8"),achangeCase) | ||
pdb.gimp_text_layer_set_text(layer,text) | ||
### main function ### | ||
pdb.gimp_image_undo_group_start(img) | ||
### get active layer | ||
draw = img.active_layer | ||
|
||
### only do if active layer is a group | ||
if allgroup: | ||
dogroup(img) | ||
elif (type(draw) == gimp.GroupLayer): | ||
dogroup(draw) | ||
pdb.gimp_image_undo_group_end(img) | ||
def changeCaseText(text,indexCase): | ||
# REMOVE Byte Order Mark \xef\xbb\xbf | ||
text=text.lstrip(codecs.BOM_UTF8.decode("utf8", "strict")) | ||
if selectionCase[indexCase]=="lowercase": | ||
return text.lower() | ||
elif selectionCase[indexCase]=="UPPERCASE": | ||
return text.upper() | ||
elif selectionCase[indexCase]=="Title": | ||
return text.title() | ||
elif selectionCase[indexCase]=="Capitalize": | ||
# pdb.gimp_message(text) | ||
# pdb.gimp_message(text.capitalize()) | ||
return text.capitalize() | ||
elif selectionCase[indexCase]=="Sentence": | ||
return re.sub(r"(^|[?!.] )(\w)",lambda x:x.group(0).upper(),text.lower()) | ||
else: | ||
return text | ||
register( | ||
"python_fu_changeFont", | ||
"Change Font, size, letter spacing, line spacing, remove style", | ||
"Nothing", | ||
"Anonymous", | ||
"1.1.0", | ||
"2019", | ||
"Change Font...", | ||
"*", | ||
[ | ||
(PF_IMAGE,"image","Input image", None), | ||
(PF_DRAWABLE,"drawable", "Input drawable", None), | ||
(PF_TOGGLE, "bfont", "Change font", True), | ||
(PF_FONT, "font", "Font", "Sans"), | ||
(PF_TOGGLE, "bcolorfont", "Change font color", False), | ||
(PF_COLOUR,"colorFont", "Font color",(0.0, 0.0, 0.0)), | ||
(PF_TOGGLE, "bsize", "Change font size", False), | ||
(PF_SPINNER, "size", "Font size", 10, (1, 8192, 1)), | ||
(PF_TOGGLE, "bscale", "Change font scale", False), | ||
(PF_SPINNER, "scale", "Font scale", 1, (0.1, 10, 0.01)), | ||
(PF_TOGGLE, "bletterspacing", "Change letter spacing", False), | ||
(PF_SPINNER, "letterspacing", "letter spacing", 0, (-100, 100, 0.1)), | ||
(PF_TOGGLE, "blinespacing", "Change line spacing", False), | ||
(PF_SPINNER, "linespacing", "line spacing", 0, (-100, 100, 0.1)), | ||
(PF_TOGGLE, "cremovestyle", "Change remove style", False), | ||
(PF_OPTION,"changeCase", "Change case", 0,selectionCase), | ||
(PF_TOGGLE, "allgroup", "All Groups", True), | ||
(PF_TOGGLE, "rec", "Recurse nested groups", True) | ||
], | ||
[], | ||
py_group_chfont, | ||
menu="<Image>/Layer/Tools/" | ||
) | ||
|
||
main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env python | ||
from gimpfu import * | ||
import re | ||
nameLayers=[] | ||
def orderLayers(image, drawable,bInverse): | ||
if drawable: | ||
parent = pdb.gimp_item_get_parent(drawable) | ||
if not parent: | ||
parent=image | ||
pdb.gimp_image_undo_group_start(image) | ||
for layer in parent.layers: | ||
nameLayers.append(layer.name) | ||
if parent==image: | ||
parent = None | ||
for namelayer in natural_sort(nameLayers,not bInverse): | ||
item = pdb.gimp_image_get_layer_by_name(image, namelayer) | ||
pdb.gimp_image_reorder_item(image, item, parent, 0) | ||
pdb.gimp_image_undo_group_end(image) | ||
|
||
|
||
def natural_sort(l,Reverse=False): | ||
convert = lambda text: int(text) if text.isdigit() else text.lower() | ||
alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ] | ||
return sorted(l, key = alphanum_key, reverse=Reverse) | ||
register( | ||
"python_fu_OrderLayers", | ||
"Sort the layers", | ||
"Nothing a", | ||
"Anonymous a", | ||
"1.1.0", | ||
"2020", | ||
"Order Layers...", | ||
"*", | ||
[ | ||
(PF_IMAGE,"image","Input image", None), | ||
(PF_DRAWABLE,"drawable", "Input drawable", None), | ||
(PF_TOGGLE, "bInverse", "Reverse", False), | ||
], | ||
[], | ||
orderLayers, | ||
menu="<Image>/Layer/Tools/" | ||
) | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env python | ||
from gimpfu import * | ||
import gimpfu | ||
import re | ||
import subprocess | ||
import inspect | ||
import sys | ||
import os | ||
def ParentLayerGroup(img, Drawable,sPrefix,bRemove,sSufix,iOrderGroup,bRoot): | ||
def childrenreOrder(g): | ||
for layer in g.layers: | ||
if (type(layer) == gimp.GroupLayer): | ||
childrenreOrder(layer) | ||
else: | ||
pdb.gimp_image_reorder_item(img,layer,None,0) | ||
iOrderGroup=int(iOrderGroup) | ||
pdb.gimp_image_undo_group_start(img) | ||
if bRoot==True: | ||
childrenreOrder(img) | ||
else: | ||
NoLayers, IDLayers = pdb.gimp_image_get_layers(img) | ||
for IDLayer in IDLayers: | ||
Layer = gimp._id2drawable(IDLayer) | ||
if pdb.gimp_item_is_group(Layer) == False: | ||
if bRemove: | ||
NameGroup = re.sub(sSufix, "", Layer.name) | ||
else: | ||
NameGroup = Layer.name | ||
layerGroup = pdb.gimp_image_get_layer_by_name(img, sPrefix + NameGroup) | ||
if layerGroup is None: | ||
layerGroup = pdb.gimp_layer_group_new(img) | ||
layerGroup.name = sPrefix + NameGroup | ||
img.add_layer(layerGroup,iOrderGroup) | ||
if iOrderGroup>=0: | ||
pdb.gimp_image_reorder_item(img,Layer,layerGroup,iOrderGroup) | ||
else: | ||
pdb.gimp_image_reorder_item(img,Layer,layerGroup,len(layerGroup.layers)+iOrderGroup+1) | ||
|
||
pdb.gimp_image_undo_group_end(img) | ||
|
||
register( | ||
"python_fu_ParentGroupLayer", | ||
"It allows to group the images that are in the root within a group", | ||
"Nothing", | ||
"Anonymous", | ||
"1.1.0", | ||
"2019", | ||
"ParentLayerGroup...", | ||
"RGB*, GRAY*", | ||
[ | ||
(PF_IMAGE,"image","Input image", None), | ||
(PF_DRAWABLE,"drawable", "Input drawable", None), | ||
(PF_STRING, "sPrefix", "Prefix for Groups", "G_"), | ||
(PF_TOGGLE, "bRemove", "Remove Sufix in name file.jpg #1", False), | ||
(PF_STRING, "sSufix", "Remove Sufix (regEx)", r"\.\w{1,6}( #\d+)$"), | ||
(PF_SPINNER, "iOrderGroup", "Position layer in group", 1, (-999, 999, 1)), | ||
(PF_TOGGLE, "bRoot", "All layers to Root", False), | ||
], | ||
[], | ||
ParentLayerGroup, | ||
menu="<Image>/Layer/Tools/" | ||
) | ||
main() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env python | ||
from gimpfu import * | ||
def quickView(image): | ||
def key_Q(): | ||
import ctypes | ||
keybd_event = ctypes.windll.user32.keybd_event | ||
keybd_event(0x10 , 0, 0, 0) #shift | ||
keybd_event(0x51,0,0,0)#key_Q | ||
keybd_event(0x10 , 0, 0x0002, 0) #release shift | ||
pdb.gimp_selection_flood(image) | ||
key_Q() | ||
|
||
register( | ||
"python_fu_QuickMaskRemoveHoles", | ||
"Remove the holes from the selection, and change to Quick Mask", | ||
"Nothing a", | ||
"Anonymous a", | ||
"1.1.0", | ||
"2020", | ||
"Change Quick Mask", | ||
"*", | ||
[ | ||
(PF_IMAGE,"image","Input image", None), | ||
], | ||
[], | ||
quickView, | ||
menu="<Image>/Layer/Tools/" | ||
) | ||
main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/usr/bin/env python | ||
from gimpfu import * | ||
import gimpfu | ||
import gtk | ||
import re | ||
layerSelected = [] | ||
def removeLayers(img, Drawable,sSelection,sName,bFullName,bRemoveGroups,bRemoveLayers): | ||
def remLayersChildren(G): | ||
for Layer in G.layers: | ||
Object = re.search( sName, Layer.name, flags=re.IGNORECASE) | ||
if pdb.gimp_item_is_group(Layer): | ||
remLayersChildren(Layer) | ||
if not Object : | ||
continue | ||
elif (pdb.gimp_item_is_group(Layer) == True and bRemoveGroups==False): | ||
continue | ||
elif bRemoveLayers==False and pdb.gimp_item_is_group(Layer)==False: | ||
continue | ||
else: | ||
pdb.gimp_image_remove_layer(img, Layer) | ||
pdb.gimp_progress_pulse() | ||
def listGuiRun(): | ||
def fillList(L,ls): | ||
for Layer in L.layers: | ||
if pdb.gimp_item_is_group(Layer): | ||
if bRemoveGroups: | ||
ls.append([Layer.name]) | ||
fillList(Layer,ls) | ||
|
||
else: | ||
if pdb.gimp_item_is_drawable(Layer): | ||
if bRemoveLayers: | ||
ls.append([Layer.name]) | ||
ls = gtk.ListStore(str) | ||
fillList(img,ls) | ||
scroll=gtk.ScrolledWindow() | ||
tv = gtk.TreeView(ls) | ||
col = gtk.TreeViewColumn("Layers/Groups", gtk.CellRendererText(), text=0) | ||
tv.set_reorderable(True) | ||
col.set_sort_column_id(0) | ||
tv.append_column(col) | ||
sel = tv.get_selection() | ||
sel.set_mode(gtk.SELECTION_MULTIPLE) | ||
dialog = gtk.Dialog("Selection Layers",None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,gtk.STOCK_OK, True)) | ||
dialog.resize(400, 400) | ||
scroll.add_with_viewport(tv) | ||
scroll.show() | ||
dialog.vbox.pack_start(scroll) | ||
tv.show() | ||
response = dialog.run() | ||
(model, pathlist) = sel.get_selected_rows() | ||
dialog.destroy() | ||
if not response==True: | ||
return | ||
for path in pathlist : | ||
tree_iter = model.get_iter(path) | ||
value = model.get_value(tree_iter,0) | ||
layerSelected.append(value) | ||
return | ||
|
||
pdb.gimp_image_undo_group_start(img) | ||
if (bFullName): | ||
sName="^" + sName + "$" | ||
gimp.progress_init("REMOVING LAYERS") | ||
pdb.gimp_progress_end() | ||
if sSelection: | ||
remLayersChildren(img) | ||
else: | ||
listGuiRun() | ||
for name in layerSelected: | ||
Layer=pdb.gimp_image_get_layer_by_name(img, name) | ||
pdb.gimp_image_remove_layer(img, Layer) | ||
pdb.gimp_image_undo_group_end(img) | ||
|
||
register( | ||
"python_fu_RemLayer", | ||
"Remove layers by selection or name(Regex)", | ||
"Nothing a", | ||
"Anonymous a", | ||
"1.1.0", | ||
"2020", | ||
"Remove Layers...", | ||
"RGB*, GRAY*", | ||
[ | ||
(PF_IMAGE,"image","Input image", None), | ||
(PF_DRAWABLE,"drawable", "Input drawable", None), | ||
(PF_OPTION, "sSelection", "Remove By",0,("Layer Selection","Name")), | ||
(PF_STRING, "sName", "Name Layer", "Name"), | ||
(PF_TOGGLE, "bFullName", "Remove only if is Name Complete", True), | ||
(PF_TOGGLE, "bRemoveGroups", "Groups", False), | ||
(PF_TOGGLE, "bRemoveLayers", "Layers", True), | ||
], | ||
[], | ||
removeLayers, | ||
menu="<Image>/Layer/Tools/" | ||
) | ||
main() |
Oops, something went wrong.