Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
public static void ProcessDirectory(string targetDirectory)
   {

       // string[] fileEntries = Directory.GetFiles(targetDirectory, "*.jpg");
       var fileEntries = Directory.GetFiles(targetDirectory, "*.jpg");
       //if (photos.Count() == 0)
       //{
       //    Response.Redirect("~/Images/gallery-empty.png");
       //    return;
       //}
       // Process the list of files found in the directory.



       using (var generator = new MultiThumbnailGenerator())
       {
           foreach (var photo in fileEntries)
           {
               using (var imageStream = new System.IO.MemoryStream(photo.FileContents)) //error
               {
                   using (var image = System.Drawing.Image.FromStream(imageStream))
                   {
                       generator.AddImage(image);
                   }
               }
           }
           using (var outStream = new System.IO.MemoryStream())
           {
               generator.WritePngToStream(outStream);
               // var image = new WebImage(outStream);
               //   image.Write();
           }
       }
   }



*MultiThumbnailGenerator is a class where i am generating thumbnail of many images of the folder , in that thumbnail all the images have lightly display,,,


I have an outstream (of many images to develop an image) ,I googled it but my requirement is ASP.net 3.5.

how to generate,create,save the outstream as an image
Posted
Updated 6-Jan-13 9:50am
v2

1 solution

This has not changed in how it works for a long time. I don't see how there could be anything new in ASP.NET 4, I did this in 1.1. You create a HTTP handler and on the URL that handler processes, you pass an id. That id tells you what image to look up in your DB. You write those bytes to the output stream. Your browser uses the URL to access the image, and gets back the bytes of the image.
 
Share this answer
 
Comments
Ali_100 6-Jan-13 15:51pm    
I am sorry christian graus,i dont know how there is mistakenly half pasting in the QUestion,,
well now i updated it,
Christian Graus 6-Jan-13 15:53pm    
Why are you using var for types you know ? What is the problem here ? One http request cannot return many images. You can only return one image at a time.
Ali_100 6-Jan-13 16:23pm    
I am not much experience ,actually it was a code from webmatrix,which i use in 3.5,, now i am trying to use httphandler,,, ok I am using http handler,, can you give me any example ... or tell me from where should i do that first...
Christian Graus 6-Jan-13 16:25pm    
Too many people on this site have 'not much experience' and get by in paid jobs because we do the work for them. It's not a long term strategy for you. Buy some books and try to learn, don't just rely on us.

Also, try to search the site before you ask. I think http://www.codeproject.com/Articles/16120/Thumbnailer-HTTP-Handler is exactly what you need.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900