Shinnen
Member
Hi,
I have no idea where to post this, so here goes.
I want to reduce the size of a jpg, and at the same time maintain it's clarity.
None of the editors I have will do this. They all look blurry after the reduction.
So, I went on line looking for a program, and found a site that gives a code for doing this.
The problem is that I have NO idea what to do with this code OR how to use it on my
jpg. Here's the code. I'm hoping that someone can advise me about what to do with it.
Thanks,
...... john
publicvoid ResizeImage(double scaleFactor, Stream fromStream, Stream toStream)
{
var image = Image.FromStream(fromStream);
var newWidth = (int)(image.Width * scaleFactor);
var newHeight = (int)(image.Height * scaleFactor);
var thumbnailBitmap = newBitmap(newWidth, newHeight);
var thumbnailGraph = Graphics.FromImage(thumbnailBitmap);
thumbnailGraph.CompositingQuality = CompositingQuality.HighQuality;
thumbnailGraph.SmoothingMode = SmoothingMode.HighQuality;
thumbnailGraph.InterpolationMode = InterpolationMode.HighQualityBicubic;
var imageRectangle = new Rectangle(0, 0, newWidth, newHeight);
thumbnailGraph.DrawImage(image, imageRectangle);
thumbnailBitmap.Save(toStream, image.RawFormat);
thumbnailGraph.Dispose();
thumbnailBitmap.Dispose();
image.Dispose();
}
I have no idea where to post this, so here goes.
I want to reduce the size of a jpg, and at the same time maintain it's clarity.
None of the editors I have will do this. They all look blurry after the reduction.
So, I went on line looking for a program, and found a site that gives a code for doing this.
The problem is that I have NO idea what to do with this code OR how to use it on my
jpg. Here's the code. I'm hoping that someone can advise me about what to do with it.
Thanks,
...... john
publicvoid ResizeImage(double scaleFactor, Stream fromStream, Stream toStream)
{
var image = Image.FromStream(fromStream);
var newWidth = (int)(image.Width * scaleFactor);
var newHeight = (int)(image.Height * scaleFactor);
var thumbnailBitmap = newBitmap(newWidth, newHeight);
var thumbnailGraph = Graphics.FromImage(thumbnailBitmap);
thumbnailGraph.CompositingQuality = CompositingQuality.HighQuality;
thumbnailGraph.SmoothingMode = SmoothingMode.HighQuality;
thumbnailGraph.InterpolationMode = InterpolationMode.HighQualityBicubic;
var imageRectangle = new Rectangle(0, 0, newWidth, newHeight);
thumbnailGraph.DrawImage(image, imageRectangle);
thumbnailBitmap.Save(toStream, image.RawFormat);
thumbnailGraph.Dispose();
thumbnailBitmap.Dispose();
image.Dispose();
}