public static byte[] GetThumbnail(this byte[] imageBytes, int width, int height) { try { using (MemoryStream streamInput = new MemoryStream(imageBytes)) { System.Drawing.Image image = new Bitmap(streamInput); System.Drawing.Image.GetThumbnailImageAbort deleg = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback); System.Drawing.Image thumbnail = image.GetThumbnailImage(width, height, deleg, IntPtr.Zero); byte[] result = thumbnail.GetBytes(image.RawFormat); return(result); } } catch (Exception ex) { return(imageBytes); } }