Arbitrary image count in either direction

This version adds support for an arbitrary image count in any direction.