BgEngine.Controllers.ApiController.GetThumbnail C# (CSharp) Method

GetThumbnail() public method

public GetThumbnail ( string url ) : void
url string
return void
        public void GetThumbnail(string url)
        {
            if (url != null)
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                WebImage image = new WebImage(response.GetResponseStream());

                var iwidth = image.Width;
                var iheight = image.Height;

                if (iwidth >= iheight)
                {
                    var leftRightCrop = (iwidth - iheight) / 2;
                    image.Crop(0, leftRightCrop, 0, leftRightCrop).Write();
                }
                else if (iheight > iwidth)
                {
                    var topBottomCrop = (iheight - iwidth) / 2;
                    image.Crop(topBottomCrop, 0, topBottomCrop, 0).Write();
                }
            }
            else
            {
                new WebImage("~/Content/Icons/no_image.jpg").Crop(1,1).Write();
            }
        }