Rotate thumbnail when encryption is enabled

When a picture is encrypted, save it to a temporary file first so that
the PHP function for rotation can access it as file.

I'm not too thrilled about this solution as it involves temporary files.
Besides, inside the slideshow the pic is still rotated, but a recent PR that renders the slideshow with thumbnails might fix that.

Obviously I'd prefer having a library that can read directly from streams.

Such issue also exists in core for the small previews.

Let's discuss @DeepDiver1975 @georgehrke @schiesbn