Reorderd processing order to prevent edge artifacts from being introduced during image rotation.