Hi,
I am stuck with this problem. We need to create high resolution and quality images as the website is related to printing so when customer images are printed they have to be downloaded in big resolution according to the size. The biggest size we do is 130 cm one side so if the image is high quality we regularly get Out of Memory exception while creating the image. I have been using .Net bitmap, Graphics code for this but still not getting better for high resolution images so I tried to use third party controls hence trying GdPictures. Here is the code I have written just to check if it can handle.
var newBitMapGD = new GdPictureImaging();
int imgId = newBitMapGD.CreateGdPictureImageFromBitmap(b);
var status = newBitMapGD.Resize(imgId, 21000, 6000, System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic);
Bitmap returnBmp = newBitMapGD.GetBitmapFromGdPictureImage(imgId);
var delStatus = newBitMapGD.ReleaseGdPictureImage(imgId);
return returnBmp;
As you can see the Resize has 21000 width and 6000 height. This is giving Out of Memory exception which we get in normal .Net code as well as it doesn't handle Width/Height more than 10k normally and fall over. We have a dedicated server with 125GB Ram so I don't know why IIS won't use that. Can someone please help?
Here is the normal .Net function which we use;
public virtual Bitmap ResizeImage(Bitmap b, int targetSizeWidth = 0, int targetSizeHeight = 0, string fileExtension = "jpg")
{
var newSize = CalculateDimensions(b.Size, targetSizeWidth, targetSizeHeight);
if (newSize.Width < 1)
newSize.Width = 1;
if (newSize.Height < 1)
newSize.Height = 1;
var newBitMap = new Bitmap(newSize.Width, newSize.Height); Falls over here with 20000 width
var g = Graphics.FromImage(newBitMap);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
g.DrawImage(b, 0, 0, newSize.Width, newSize.Height);
b.Dispose();
var ep = new EncoderParameters();
ep.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, this.ImageQuality);
ImageCodecInfo ici = GetImageCodecInfoFromExtension(fileExtension);
if (ici == null)
ici = GetImageCodecInfoFromMimeType("image/jpeg");
return newBitMap;
}
Using GdPictures in MVC .net C#
-
- Posts: 352
- Joined: Tue Sep 27, 2011 11:47 am
Re: Using GdPictures in MVC .net C#
Hi,
Are you sure you are running your application under X64? I tried resizing an image to 21000 * 6000 and I could easily achieve that with GdPicture.
Best,
Sami
Are you sure you are running your application under X64? I tried resizing an image to 21000 * 6000 and I could easily achieve that with GdPicture.
Best,
Sami
Who is online
Users browsing this forum: No registered users and 1 guest