logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
sweeperqb  
#1 Posted : Friday, April 2, 2021 2:02:52 PM(UTC)
sweeperqb

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);
        }
    }
}

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

Users browsing this topic
Guest (4)
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.