python-fu-divide-layer / layer-slice.py

bworkman 74772ca 


























































#!/usr/bin/env python

# Save or export the current image -- do the right thing whether it's
# XCF (save) or any other format (export). This will mark the image clean,
# so GIMP won't warn you when you exit.
# Warning: this does not show a lot of extra dialogs, etc. or warn you
# if you're about to overwrite something! Use with caution.

# Copyright 2012 by Akkana Peck, http://www.shallowsky.com/software/
# You may use and distribute this plug-in under the terms of the GPL v2
# or, at your option, any later GPL version.

from gimpfu import *
import gtk
import os
import collections
import ctypes

def slice_layer(img, drawable, width, height) :

        MessageBox = ctypes.windll.user32.MessageBoxA

        for i in range(img.width / width + 1):
                for j in range(img.height / height + 1):
                        MessageBox(None, 'Slice (' + str(i) + ',' + str(j) + ')', 'Window title', 0)

        return None

register(
        #name
        "layer_slice",
        #blurb
        "<blurb>",
        #help
        "<help text>",
        #author
        "<author>",
        #copyright
        "<copyright>",
        #date
        "<date>",
        #menu path
        "<Image>/Layer/Slice",
        #image types
        "*",
        #params
        [
                #(type, name, description, default [, extra])
            #(PF_IMAGE, "image", "Input image", None),
            #(PF_DRAWABLE, "drawable", "Input drawable", None),
            (PF_INT, "width", "px slice width", None),
            (PF_INT, "height", "pc slice height", None),
        ],
        #results
        [],
        #function
        slice_layer
)

main()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.