private static Surface GetOrientedSurface(byte[] bytes, out ExifValueCollection exifMetadata) { exifMetadata = null; Surface surface = WebPFile.Load(bytes); byte[] exifBytes = WebPFile.GetExifBytes(bytes); if (exifBytes != null) { exifMetadata = ExifParser.Parse(exifBytes); if (exifMetadata != null) { ExifValue orientationProperty = exifMetadata.GetAndRemoveValue(ExifPropertyKeys.Image.Orientation.Path); if (orientationProperty != null) { MetadataHelpers.ApplyOrientationTransform(orientationProperty, ref surface); } } } return(surface); }