i've gotten around this by naming my images with sequential numbers. then you can just have a constant you change that holds the number of the largest image and you can use that to construct your loop ...
it's just too common a set of terms for google to be helpful. I'm looking for code to take an image, scale it to fit within certain constraints (i.e. set display height or width <= X and then rotate ...