Ipad camera image changes orientation

iPhone - Camera image changes orientation


EXIF stands for "Exchangeable Image File Format".
When processing photos, sometimes you want to re-orient the photo according the orientation recorded by the camera (such as the iPhone’s accelerometer) and stored in the EXIF meta data. It’s easy to do:
public static void FixOrientation(this Image image)
{
    // 0x0112 is the EXIF byte address for the orientation tag
    if (!image.PropertyIdList.Contains(0x0112))
    {
        return;
    }

    // get the first byte from the orientation tag and convert it to an integer
    var orientationNumber = image.GetPropertyItem(0x0112).Value[0];

    switch (orientationNumber)
    {
        // up is pointing to the right
        case 8:
            image.RotateFlip(RotateFlipType.Rotate270FlipNone);
            break;
        // up is pointing to the bottom (image is upside-down)
        case 3:
            image.RotateFlip(RotateFlipType.Rotate180FlipNone);
            break;
        // up is pointing to the left
        case 6:
            image.RotateFlip(RotateFlipType.Rotate90FlipNone);
            break;
        // up is pointing up (correct orientation)
        case 1:
            break;
    }
}
Must include using System.Linq
Ipad camera image changes orientation Ipad camera image changes orientation Reviewed by Bhaumik Patel on 9:27 AM Rating: 5