fix for #152: rotate images for correct orientation (gallery)

code taken from user "Germar" supplied in the issue comments