This will properly rotate photos that have EXIF rotation information, but I'm worried that it will mess up the thumbnails that are based on video poster images.  Note that you're passing in rotation and mirrored values but are not using them anywhere anymore.

For photos from the camera, if you don't pass in the image size and orientation data, it will get that information from the photo with getImageSize(). But for the video poster image case there will not be any EXIF information saying that it needs rotation

To fix this, you need to pass your own metadata object, I think.  You could use getImageSize() to get metadata and the override the rotation and mirrored flags with that.  Or maybe you already know the size of the image and could just pass that in to this function.

Anyway, please check the video thumbnail case.  You might want to look at how I handled that for 1.3T. I don't remember. Maybe I used the old code path (without cropResizeRotate()) for videos? Or maybe I just was able to pass the appropriate metadata in.