Fix the rotation problem and check if we're still inside the image