public ActionResult Image(string imageFile, int? width, int? height, int? id)
 {
     var memoryStream = new MemoryStream();
     var image = new Bitmap(ObjectsRepository.CatalogFolder + imageFile.Replace("___", "/"));
     if (width != null && height != null)
     {
         image = image.Clip10X15();
         image = image.ResizeImage(width.Value, height.Value);
     }
     if (id != null)
     {
         image = image.AddBluredRect(30);
         var htmlText = ObjectsRepository.GetObjectDescription(id.Value);
         if (!string.IsNullOrEmpty(htmlText))
         {
             image = image.AddText(30, 0, htmlText);
         }
         //var backImage = new Bitmap(Server.MapPath("~\\Content\\images\\keyend.png"));
         //image = image.AddBackBitmap(backImage);
     }
     image.Save(memoryStream, ImageFormat.Jpeg);
     memoryStream.Seek(0, SeekOrigin.Begin);
     return File(memoryStream, "image/jpeg");
 }
        public static Bitmap CombineBitmap(IEnumerable<string> files)
        {
            //read all images into memory
            List<Bitmap> images = new List<Bitmap>();
            Bitmap finalImage = null;

            try
            {
                int width = 0;
                int height = 0;

                foreach (string filename in files)
                {
                    // create a Bitmap from the file and add it to the list
                    Bitmap bitmap = new Bitmap(filename);

                    // update the size of the final bitmap
                    width += bitmap.Width;
                    height = bitmap.Height > height ? bitmap.Height : height;

                    images.Add(bitmap);
                }

                // create a bitmap to hold the combined image
                finalImage = new Bitmap(width, height);

                // get a graphics object from the image so we can draw on it
                using (Graphics g = Graphics.FromImage(finalImage))
                {
                    // set background color
                    g.Clear(Color.Transparent);

                    // go through each image and draw it on th final image
                    foreach (Bitmap image in images)
                    {
                        g.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height));
                    }
                }

                var destRect = new Rectangle(0, finalImage.Height / 3, finalImage.Width, finalImage.Height / 3);
                return finalImage.AddBluredRect(destRect);
            }
            catch (Exception)
            {
                if (finalImage != null) finalImage.Dispose();
                throw;
            }
            finally
            {
                // clean up memory
                foreach (Bitmap image in images)
                {
                    image.Dispose();
                }
            }
        }