Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # ffmpeg -i *.gif -r 6.0 `basename *.gif .gif`%4d.png; gimp-console -i -b '(python-fu-batch-spritify RUN-NONINTERACTIVE "*.png")'
- import math
- from gimpfu import *
- def batch_spritify(glob="*.png"):
- files = pdb.file_glob(glob, 1)
- for file in files[1]:
- timg = pdb.gimp_file_load(file, file)
- tdrawable = pdb.gimp_image_get_active_drawable(timg)
- pdb.gimp_image_undo_group_start(timg)
- pdb.gimp_desaturate_full(tdrawable, DESATURATE_LIGHTNESS)
- pdb.gimp_image_convert_indexed(timg, NO_DITHER, CUSTOM_PALETTE, 0, FALSE, FALSE, "RGBDS")
- pdb.gimp_image_scale_full(timg, tdrawable.width/2, tdrawable.height/2, INTERPOLATION_NONE)
- pdb.gimp_image_resize(timg, 56, 56, (56-tdrawable.width)/2, (56-tdrawable.height)/2)
- pdb.gimp_image_convert_grayscale(timg)
- pdb.gimp_image_flatten(timg)
- pdb.file_png_save_defaults(timg, pdb.gimp_image_get_active_drawable(timg), pdb.gimp_image_get_filename(timg), pdb.gimp_image_get_filename(timg))
- pdb.gimp_image_undo_group_end(timg)
- pdb.gimp_quit(0)
- register(
- "batch_spritify",
- "Make the specified layer look like a sprite",
- "Make the specified layer look like a sprite",
- "Danny-E 33",
- "Danny-E 33",
- "2019-2019",
- "<Toolbox>/Python-Fu/_BatchSpritify...",
- "RGB*",
- [
- (PF_STRING, "glob", "glob", "*.png")
- ],
- [],
- batch_spritify)
- main()
Add Comment
Please, Sign In to add comment