Optimizing looping and unlinking of the resized images