Skip to content

Instantly share code, notes, and snippets.

@Shoeboxam
Created December 16, 2014 18:33
Show Gist options
  • Save Shoeboxam/25ac453afc5582d6f874 to your computer and use it in GitHub Desktop.
Save Shoeboxam/25ac453afc5582d6f874 to your computer and use it in GitHub Desktop.
Gimp Normalmap bugged script
#!/usr/bin/env python
from gimpfu import *
import glob
import sys
import os
def normalmap_wrapper(glob_pattern, source):
sys.stderr = open('C:\Users\mike_000\Desktop\errorstream.txt', 'a')
sys.stdout = open('C:\Users\mike_000\Desktop\outstream.txt', 'a')
def modify_path(insertion):
filename = image.filename
index_insertion = filename.find(".png")
return filename[:index_insertion] + insertion + filename[index_insertion:]
glob_paths = glob.glob(source + os.sep + glob_pattern)
for path in glob_paths:
print(path)
image = pdb.gimp_file_load(path, path)
drawable = pdb.gimp_image_get_active_layer(image)
pdb.plug_in_normalmap(image, drawable, 0, .04, 6, 1, 0, 1, 0, 0, 0, 1, 0, 0, drawable)
path_n = modify_path('_n')
pdb.gimp_file_save(image, drawable, path_n, path_n)
register(
"plug-in-normalmap-wrapper",
"Normalmap Autorun",
"Convert texture tile to normal map using Normalmap plugin",
"Alias: Shoeboxam",
"Shoeboxam 2014", #Copyright
"2014/12/10",
N_("Normalmap Auto..."),
"",
[
(PF_STRING, "glob_pattern", "Glob Pattern", "*.*"),
(PF_STRING, "source", "Source Directory", "")
],
[],
normalmap_wrapper,
menu="<Image>/Filters/Map/",
domain=("gimp20-python", gimp.locale_directory)
)
main()
#pdb.plug_in_normalmap(image, drawable, 0, .04, 6, 1, 0, 1, 0, 0, 0, 1, 0, 0, drawable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment