Bitmap source = (Bitmap)Image.FromFile(path);
if (Array.IndexOf(source.PropertyIdList, 274) > -1)
{
var orientation = (int)source.GetPropertyItem(274).Value[0];
switch (orientation)
{
case 1:
// No rotation required.
break;
case 2:
source.RotateFlip(RotateFlipType.RotateNoneFlipX);
break;
case 3:
source.RotateFlip(RotateFlipType.Rotate180FlipNone);
break;
case 4:
source.RotateFlip(RotateFlipType.Rotate180FlipX);
break;
case 5:
source.RotateFlip(RotateFlipType.Rotate90FlipX);
break;
case 6:
source.RotateFlip(RotateFlipType.Rotate90FlipNone);
break;
case 7:
source.RotateFlip(RotateFlipType.Rotate270FlipX);
break;
case 8:
source.RotateFlip(RotateFlipType.Rotate270FlipNone);
break;
}
// This EXIF data is now invalid and should be removed.
source.RemovePropertyItem(274); this.actualBitmap = _images[0];
}
Comments
Post a Comment