Created
August 30, 2010 13:31
-
-
Save branch14/557394 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
# (c) 2010 Phil Hofmann <[email protected]> | |
import os | |
from gimpfu import * | |
def batch_make_textures(input_pattern, output_path, output_prefix, size): | |
if not os.path.exists(output_path): | |
os.makedirs(output_path) | |
num_files, file_names = pdb.file_glob(input_pattern, 1) | |
for file_name in file_names: | |
short_name = file_name[2:-4] | |
image = pdb.gimp_file_load(file_name, file_name) | |
width = pdb.gimp_image_width(image) | |
height = pdb.gimp_image_height(image) | |
pdb.gimp_image_crop(image, width, width, 0, height - width) | |
pdb.gimp_image_scale(image, size, size) | |
drawable = pdb.gimp_image_get_active_layer(image) | |
pdb.plug_in_make_seamless(image, drawable) | |
new_file_name = output_path + '/' + output_prefix + short_name + '.jpg' | |
pdb.file_jpeg_save(image, drawable, | |
new_file_name, new_file_name, | |
1.0, 0.0, 1, 0, "", 0, 1, 0, 1) | |
register('batch_make_textures', | |
'Convert a couple of files to seamless textures (jpeg)', | |
'Convert a couple of files to seamless textures (jpeg)', | |
'Phil Hofmann', | |
'Phil Hofmann', | |
'2010', | |
'Batch Make Textures...', | |
'', | |
[ (PF_STRING, 'input_pattern', 'Input pattern', './*.jpg'), | |
(PF_STRING, 'output_path', 'Output path', 'output'), | |
(PF_STRING, 'output_prefix', 'Output prefix', 'texture_'), | |
(PF_INT, 'size', 'Size', 256) ], | |
[], | |
batch_make_textures, | |
menu="<Image>/Filters") | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment