Getting and Saving Thumbnail Image from Orginal Image in webpage using System.Drawing c#

Getting Thumbnail Image from Orginal Image using System.Drawing c#

 

 

//Getting Thumbnail of orginal Image

        public void GetThumbnail()

        {

            //Just an simple call back.

            Image.GetThumbnailImageAbort myCallback =

            new Image.GetThumbnailImageAbort(ThumbnailCallback);

 

            //Getting image from the path.

            Bitmap myBitmap = new Bitmap(Server.MapPath("scenary.jpg"));

 

            //Convert Image as Thumbnail with given size.

            Image myThumbnail = myBitmap.GetThumbnailImage(

            40, 40, myCallback, IntPtr.Zero);

 

            //Get the current response

            HttpResponse response = GetHttpResponse();

 

            //Saves image to the Page in the PNG format

            myThumbnail.Save(response.OutputStream, ImageFormat.Png);

        }

 

        public bool ThumbnailCallback()

        {

            return false;

        }

 

Thanks for reading this article. Have a nice day.