0

7 years ago, resizing an image in C# in an ASP.NET application looked to be a mined operation. There were three different approaches. System.Drawing was not server safe. WebImage was apparently a disaster. Wrappers for native code that needed full trust. Memory leaks. Various 3rd party plugins.

The thing is, all the information is old and nothing seems to have changed. Do these links still represent state of the art? Can this be done with System classes without taking your life in your hands? Seemingly not?

bbsimonbb
  • 27,056
  • 15
  • 80
  • 110

1 Answers1

0

Use System.Drawing.Graphics.DrawImage (you need to first generate an empty bitmap holder with Graphics.FromImage()), and keep the same ratio when you calculate the new width height. I'm currently using such an approach and haven't got into any issues yet, this approach doesn't "blur" the image in a any way, if you keep the proper ratio as the original image had. I am using this on a rest api (server side). Possible duplicate of : Resize an Image C#

Community
  • 1
  • 1
Andrei Filimon
  • 1,138
  • 8
  • 12
  • Are you sure you read my question? You link to a 7 year old answer, that uses the System.Drawing namespace. MSDN explicitly warns against using this on servers. – bbsimonbb Jan 23 '17 at 13:12
  • Yes I did,they say you "might" experience crashes, well I didn't. I am using windows Azure to host the api, and blobs to store the images, everything works fine. – Andrei Filimon Jan 23 '17 at 15:20