Possible Duplicate:
PySide: Separating a spritesheet / Separating an image into contiguous regions of color
Given a .png image with transparent pixels and a grid of individual animation frames (where the last row need not be full), how would you automatically find the dimensions of each individual frame, and detect how many frames are in the .png?
I am trying to convert the resources from the creative-commons treasure-trove of Glitch into our internal format, and I am having problems isolating frame information from the raw .pngs.

(released by Glitch under http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US license)
In this case, I can find that frames are 189 x 230 px; but looking this up requires time, and there are a lot of images to potentially look up.
I would like to split the image into frames for use inside a Java Swing desktop application. I can load the image using ImageIO into a BufferedImage, and easily check for pixel transparency. There are only a few possible frame sizes: given a 945×690 frame as in the example, and assuming a minimal side of 50px, the only plausible frame-widths are 5 x 189 (correct), 7 x 135, or 9 x 105.
So, how would you find the frame size? This does not need to be tremendously efficient, as resource conversion is a one-time problem. Pseudo-code answers are fine; I am mostly interested in the algorithm.
Note: PySide: Separating a spritesheet / Separating an image into contiguous regions of color explains how to deal with non-animation sprite-sheets, with irregularly sized images within the sheet. I am interested in detecting rows x columns, which can be solved with a much simpler algorithm (see accepted answer).
Since all the images are framed by a single color, you could look for bars of ‘frame border color’ in columns and rows across the larger image.
Use the number of columns and rows obtained, in relation to the size of the image (width x height), to determine the pixel sizes of each sub-image.