There have been several topic in the Gramps mailing list regarding the issue
[Gramps-users] Gramps 4.2.5 AOI & jpg rotation | gramps and several others
The most common advice was to ensure the image is rotated using an external utility to ensure that the image rotation conforms to Gramps’s default.
This issue has bothered ne for a while, partly because even the remedies or utilities recommended, at least for me, did not work as expected and for Irfanview, for instance need a special plugin or setup to make sure the image gets saved with the ‘proper’ orientation.
The blog at: EXIF orientation handling is a ghetto | Dave Perrett
explains what needs to be done and the code attached here does the work:
with pyexiv2.Image( image) as metaImg:
metadata = metaImg.read_exif()
imgOrientation = 0
for key, value in metadata.items():
if ( b ):
print( '\n=== EXIF =================\n')
b = False
print(key, ' : ', value )
if( key == 'Exif.Image.Orientation'):
imgOrientation = value
if ( imgOrientation == '0' ):
pass
elif ( imgOrientation == '1' ):
pass
elif ( imgOrientation == '2' ):
img = img.Mirror( True ) # horizontal
pass
elif ( imgOrientation == '3' ):
img = img.Rotate180()
pass
elif ( imgOrientation == '4' ):
img = img.Mirror( False ) # vertical
pass
elif ( imgOrientation == '5' ):
img = img.Mirror( True ) # horizontal
img = img.Rotate90( False ) # CCW
pass
elif ( imgOrientation == '6' ):
img = img.Rotate90( True ) # CW
pass
elif ( imgOrientation == '7' ):
img = img.Mirror( True ) # horizontal
img = img.Rotate90( True ) # CW
pass
elif ( imgOrientation == '8' ):
img = img.Rotate90( False ) # CCW
pass
self.m_bitmapMain.SetBitmap(wx.Bitmap(img))
At present I am not yet familiar enough with the Gramps code nor with creating patches etc
I am putting this out here so that people who are interested and more familiar with all that can give it a shot.
The code above is an extract from a small wxPython test app and can prove the full code for it if anyone is interested
Test images are available at: GitHub - recurser/exif-orientation-examples: Example images for the various EXIF orientation flags, in both landscape and portrait orientation.