Read image dimensions via GDI if EXIF fails with an exception
This commit is contained in:
committed by
Sebastiaan Janssen
parent
2a930e5a66
commit
072c014055
@@ -377,21 +377,28 @@ namespace Umbraco.Core.IO
|
||||
return new Size(width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
//We will just swallow, just means we can't read exif data, we don't want to log an error either
|
||||
}
|
||||
|
||||
//we have no choice but to try to read in via GDI
|
||||
//we have no choice but to try to read in via GDI
|
||||
try
|
||||
{
|
||||
using (var image = Image.FromStream(stream))
|
||||
{
|
||||
|
||||
var fileWidth = image.Width;
|
||||
var fileHeight = image.Height;
|
||||
return new Size(fileWidth, fileHeight);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
//We will just swallow, just means we can't read exif data, we don't want to log an error either
|
||||
return new Size(Constants.Conventions.Media.DefaultSize, Constants.Conventions.Media.DefaultSize);
|
||||
//We will just swallow, just means we can't read via GDI, we don't want to log an error either
|
||||
}
|
||||
|
||||
return new Size(Constants.Conventions.Media.DefaultSize, Constants.Conventions.Media.DefaultSize);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user