Q: Resize image of the HttpFile type I am trying to upload an image to a server using an API in C#, but before uploading, I want the image to be resized. Below is the code I am using to upload the image without resizing it.
private dynamic UploadImage(dynamic parameters)
{
    var files = Request.Files;        
    var isProfilePic = Request.Form["IsProfileImage"].Value;
    string virImgpath = string.Empty;

    if (files.Count() > 0)
    {
        HttpFile file = files.FirstOrDefault();
        string _imgname = string.Empty;

        if (file.Value != null)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                //code to upload
            }

            _userRepository.SaveImage(CurrentUser.Id, (isProfilePic == "true"), _imgname); // virImgpath
            if (isProfilePic == "true")
            {
                CurrentUser.ProfileImage = virImgpath;
            }
            else
            {
                CurrentUser.BackgroundImage = virImgpath;
            }
        }
    }

    return Response.AsJson(virImgpath);
}

Now, I am trying to achieve the resizing functionality by adding the following code.
WebImage img = files.FirstOrDefault();
img.Resize(1000, 1000);
files = (IEnumerable<HttpFile>)img;

The problem is that the file is of the HttpFile type and the Resize method requires an object of the WebImage type.

A: You can create a new WebImage by using the constructor to pass in the stream
var webImage = new WebImage(file.InputStream);

webImage.Resize(...,...,...,...);

https://msdn.microsoft.com/en-us/library/gg537958(v=vs.111).aspx
