I am working on requirement where during upload image from user on ASP.net form, I need to check if user provided image is greater than 500kb then I don't need to reduce the size of the image if it is above the size then reduce the size of the image but when I tried to use FileSize property it always show 0 value. I am using below code.
using (MagickImageCollection collection = new MagickImageCollection(txtInput.Text))
{
collection.Coalesce();
foreach (MagickImage image in collection)
{
if (image.FileSize >= 500)
{
image.Quality = 50;
image.Sample(image.Width / 2, image.Height / 2);
}
}
collection.Write(txtOutput.Text);
}