| 
					
				 | 
			
			
				@@ -1207,7 +1207,7 @@ class MainWindow(QtWidgets.QMainWindow): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # apply orientation to image according to exif 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        image_pil = apply_exif_orientation(image_pil) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        image_pil = utils.apply_exif_orientation(image_pil) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         with io.BytesIO() as f: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             image_pil.save(f, format='PNG') 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1621,48 +1621,3 @@ class MainWindow(QtWidgets.QMainWindow): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     images.append(relativePath) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         images.sort(key=lambda x: x.lower()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return images 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def apply_exif_orientation(image): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    try: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        exif = image._getexif() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    except AttributeError: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        exif = None 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if exif is None: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return image 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    exif = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        PIL.ExifTags.TAGS[k]: v 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for k, v in exif.items() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if k in PIL.ExifTags.TAGS 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    orientation = exif.get('Orientation', None) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if orientation == 1: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        # do nothing 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return image 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    elif orientation == 2: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        # left-to-right mirror 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return PIL.ImageOps.mirror(image) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    elif orientation == 3: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        # rotate 180 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return image.transpose(PIL.Image.ROTATE_180) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    elif orientation == 4: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        # top-to-bottom mirror 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return PIL.ImageOps.flip(image) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    elif orientation == 5: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        # top-to-left mirror 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return PIL.ImageOps.mirror(image.transpose(PIL.Image.ROTATE_270)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    elif orientation == 6: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        # rotate 270 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return image.transpose(PIL.Image.ROTATE_270) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    elif orientation == 7: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        # top-to-right mirror 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return PIL.ImageOps.mirror(image.transpose(PIL.Image.ROTATE_90)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    elif orientation == 8: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        # rotate 90 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return image.transpose(PIL.Image.ROTATE_90) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return image 
			 |