Carl asked me to add a function to the recently-enhanced image-loading code that would be able to flip images in a strip automatically so that he wouldn't have to do it manually. It should be possible to do, even efficiently, but the shape of the code right now doesn't support it. The Image.make_strip function is sort of crufty and a bit of a mess, and I'd like to review it, but it's going to go in the "after 0.2" bucket for now.
The problem is that Image.makestrip can read strips in any of three different "formats". Image.makestrp('image') can mean:
-
a strip of one image, image.png
-
a strip of many images, image-n.png
-
a directory, image/, with images in it image/*.png. This case can be further split into:
-
a strip with an index, image/index.py
-
a strip with no index -- this case is the same as the second case.
-
In the first case, we return a strip of one image. In the second case, we look at the numbers of the files, and "fill in the gaps", so if the strip is [image-1, image-2, image-4], we convert this to [image-1, image-2, image-2, image-4]. That is to say, we repeat image-2 to fill in the gap where image-3 ought to be. This is a cute hack but it's largely superceded by the use of an index file. The index file contains only one expression which specifies the numbers of the images to load, in proper order. So if index.py reads [1, 4, 2, 1], we build a strip from [image-1, image-4, image-2, image-1]. To save memory, image-1 is loaded only once, and the surface is repeated in the strip. [P.S. if you modify the elements of the strip, weird stuff might happen; mostly we don't do that.]
Anyhow, I'm amenable to modifying the code, but it needs to either support all of these cases, or ditch the second one (the one I probably use least).
Ethan