Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# image resizing

Just working on a image uploader/resizer in my asp.net 4 web forms project. Does anyone know of a technique in C# for resizing uploaded images that could help with ones that are smaller than the minimum size required?

Obviously the quality will be suspect if resizing up the way, so has anyone found a way of possibly creating a new image that is the right size that is maybe plain white and then placing the original image on top of that white background?

Thanks

Edit - now ImageResizer.net is working well, but having a job resizing when the image is smaller. See comment below IrishChieftains answer for full details:

FINAL EDIT ################

Ok, I swear I tried this last night and it didn't work, so maybe just needed a clean browser or VS2010 restart but for anyone who's interested, here was my final solution. The key was scale=upscalecanvas :

int maxWidth = 400;
int maxHeight = 200;

ImageBuilder.Current.Build(saveLocation, saveLocation, new ResizeSettings("width=" + maxWidth + "&height=" + maxHeight + "&mode=pad&bgcolor=DDDDDD&anchor=middlecenter&scale=upscalecanvas"));

Can't rate ImageResizer.net highly enough - great program

like image 368
e-on Avatar asked Oct 08 '22 17:10

e-on


1 Answers

The best library out there is ImageResizer. If that doesn't help, then you'll end up trying it by hand...

Standardizing jpeg size in asp.net

like image 83
IrishChieftain Avatar answered Oct 10 '22 08:10

IrishChieftain