2

I am working a mvc web app. I upload a image to use it as system logo. Now if I select image and upload it, it can be replaced easily until image file is not of large dimesion. For file with large dimension i need to reduce its size to some smaller size to make it look like a system logo. Preferable size for my logo is 100x75. How can I reduce the file dimesion? THanks, kapil

2 Answers 2

3

try this. I found it in the msdn, and it works.

Bitmap map = new Bitmap(Image.FromFile("F:\\1.jpg"), new Size(20, 20)); map.Save("F:\\5.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); 
Sign up to request clarification or add additional context in comments.

Comments

2

You can use the classes that are in the System.Drawing namespace.

See this tutorial for details.

2 Comments

The code snippet will likely bring your server down (or at least cause worker process recycling) on a high-traffic site, since it doesn't take care of releasing all the used GDI+ objects right away.
Use the imageresizing.net library. It's 1 line of code to use, and < 200K added to your assembly. And it avoids the 29+ pitfalls in .NET image resizing.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.