I've got an webapplication where users can upload images. The current problem i'm running into is that the images being uploaded are being saved to the database in the original format. This causes a lot of performance issues when the images are used on a webpage. I used dotTrace to profile the application and I see significant problems when images are processed from the database.
The idea I have is to resize the image when it's uploaded to the server. Take the following example which I want the application to do when the user uploads a new image;
- User uploads an image
- The image is being resized to an size of 7.500 x 7.500 in pixels in 72 dpi
- The image is being saved into the database
- Original file gets disposed
The only stored image is the one mentioned above and the webapplication contains technology to resize this on the fly.
I've already read several topics here on SO. And most of them point me into the direction of ImageMagick. This tool is already familiar at my company, and being used in PHP projects. But are there any good and stable released C# wrappers for this tool? I already found the tools below but they're either in Béta release, Alpha Release or currently not updated.
I also found this topic on SO. In this topic the following code example is supplied;
private static Image CreateReducedImage(Image imgOrig, Size newSize)
{
var newBm = new Bitmap(newSize.Width, newSize.Height);
using (var newGrapics = Graphics.FromImage(newBm))
{
newGrapics.CompositingQuality = CompositingQuality.HighSpeed;
newGrapics.SmoothingMode = SmoothingMode.HighSpeed;
newGrapics.InterpolationMode = InterpolationMode.HighQualityBicubic;
newGrapics.DrawImage(imgOrig, new Rectangle(0, 0, newSize.Width, newSize.Height));
}
return newBm;
}
In short the questions i have;
- Are there any advantages in relation to performance using the example above?
- Is there a good and reliable C# wrapper for ImageMagick i can use to do this?
Any other good tips relating to the performance are welcome!