Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on an MVC project in which I have a user interaction form. Users can upload images through that from. Now that image has to be converted into jpeg and saved in multiple dimensions. I have used a server-side code that just saves the uploaded file and creates a thumbnail.


But this process is making my application a bit slow. Can anyone help me with a client-side code that can create the multi-dimensional images on the fly in the browser before it hits the server? In the server, I can post their images later.

What I have tried:

C#
Image image = Image.FromFile(fileName); 
Image thumb = image.GetThumbnailImage(120, 120, ()=>false, IntPtr.Zero);
thumb.Save(Path.ChangeExtension(fileName, "120"));
thumb = image.GetThumbnailImage(180, 180, ()=>false, IntPtr.Zero);
thumb.Save(Path.ChangeExtension(fileName, "180"));
thumb = image.GetThumbnailImage(300, 300, ()=>false, IntPtr.Zero);
thumb.Save(Path.ChangeExtension(fileName, "300"));
Posted
Updated 2-May-20 5:05am
Comments
Richard MacCutchan 2-May-20 11:23am    
Why not just save the image in its original format? The only time you need to resize it is when you need to display it again.
BillWoodruff 4-May-20 11:26am    
"saved in multiple dimensions" : please describe this in more detail.

also describe what MUST be done on the client side.

1 solution

You are better off leaving it server side and optimizing- otherwise you will make the user interface slow as well as increasing bandwidth.

First option would be to see if you could find some faster code to do the thumbnails.

Another option is to use asynch tasks to do the resize.

Or you could have a service running in the background which is triggered by a file-system event such as a new file, which would do the resize if the thumbnail doesn't already exist.
 
Share this answer
 
Comments
BillWoodruff 4-May-20 11:27am    
+5

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