doesnt need to open the stream if svg

This commit is contained in:
Leigh Pointer
2021-02-18 08:51:05 +01:00
parent 9411f9a62e
commit 59ba4b2e05

View File

@ -535,22 +535,21 @@ namespace Oqtane.Controllers
file.ImageHeight = 0; file.ImageHeight = 0;
file.ImageWidth = 0; file.ImageWidth = 0;
//svg has no image and height, the attributes for svg are held in the XML viewport
if(file.Extension != "svg")
{
if (Constants.ImageFiles.Split(',').Contains(file.Extension.ToLower())) if (Constants.ImageFiles.Split(',').Contains(file.Extension.ToLower()))
{ {
FileStream stream = new FileStream(filepath, FileMode.Open, FileAccess.Read); FileStream stream = new FileStream(filepath, FileMode.Open, FileAccess.Read);
//svg has no image and height, the attributes for svg are held in the XML viewport
if(file.Extension != "svg")
{
using (var image = Image.FromStream(stream)) using (var image = Image.FromStream(stream))
{ {
file.ImageHeight = image.Height; file.ImageHeight = image.Height;
file.ImageWidth = image.Width; file.ImageWidth = image.Width;
} }
}
stream.Close(); stream.Close();
} }
}
return file; return file;
} }