Rank: Advanced Member
  Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
  Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
  
	 
	
     | 
    
        
            
		      
                FileHelper.WriteImageFile occasionally rotates images on resize. I believe it is because it is ignoring EXIF data embedded in the JPEG image. This can be fixed by adding the following code to the  ImageUpload action of the  AssetsController, just after the using block:  Code:using (System.Drawing.Image originalImage = System.Drawing.Image.FromFile(tempImagePath)) 
 : Code://Check for exif data to determine orientation of camera when photo was taken and rotate to what's expected
if (originalImage.PropertyIdList.Contains(0x112)) //0x112 = Orientation
{
    var prop = originalImage.GetPropertyItem(0x112);
    if (prop.Type == 3 && prop.Len == 2)
    {
        UInt16 orientationExif = BitConverter.ToUInt16(originalImage.GetPropertyItem(0x112).Value, 0);
        if (orientationExif == 8)
        {
           originalImage.RotateFlip(RotateFlipType.Rotate270FlipNone);
        }
        else if (orientationExif == 3)
        {
           originalImage.RotateFlip(RotateFlipType.Rotate180FlipNone);
        }
        else if (orientationExif == 6)
        {
           originalImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
        }
    }
} 
  
            
	  
         
     | 
    | 
         
             
     | 
    
         
            
         
     | 
    | 
        
	
     | 
        
        
        
    
                           
	
    
        Forum Jump
         
	
    
    You cannot post new topics in this forum.
	
	You cannot reply to topics in this forum.
	
	You cannot delete your posts in this forum.
	
	You cannot edit your posts in this forum.
	
	You cannot create polls in this forum.
	
	You cannot vote in polls in this forum.
	
	
    
    
        Important Information:
        The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
        
        
More Details
        Close