简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM