I am having some trouble with Image
control in WPF.
I have one jpg file, which loads with wrong rotation and even i rotate this picture in windows (right click and rotate left/right
) there is no change in application.
Seems that there are some EXIF metadata in the image, which gets rotated together with a wrong image.
I'm reading the image from www so I do not have local file (and I don't want to have it). Here's how I'm converting byte[]
to BitmapImage
:
public static BitmapImage BitmapImageFromByteArray(Byte[] bytes)
{
MemoryStream stream = new MemoryStream(bytes);
BitmapImage image = new BitmapImage();
image.BeginInit();
image.CacheOption = BitmapCacheOption.OnLoad;
image.StreamSource = stream;
image.EndInit();
stream.Close();
stream.Dispose();
return image;
}
So there are 2 ways of handling that:
- Set
Image
control to ignore EXIF metadata - Remove EXIF metadata from
BitmapImage
Can you help me with handling any of these?