How to reduce the size of images to 40 KB while maintaining quality, and the dimensions of images are greater than 400 px , in C# ?
Note, was used:
image.GetThumbnailImage : (The size is appropriate but the dimensions are small, and the larger the dimensions the bigger the size)
Drawing : (Large size, larger than 700 KB)
Code:
System.Drawing.Bitmap newImage = new System.Drawing.Bitmap(newWidth, newHeight);
using (System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(newImage))
{
gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
gr.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
gr.DrawImage(im3age, new System.Drawing.Rectangle(new System.Drawing.Point(0, 0), new System.Drawing.Size(newWidth, newHeight)));
newImage.Save(FullPhat, System.Drawing.Imaging.ImageFormat.Jpeg);
}



newWidthandnewHeight? Try PNG instead of Jpeg, it uses lossless compression and still achieves good file sizes. Consider an algorithm like the one that tinypng uses, there is no way to maintain arbitrary high quality targets and arbitrarily low size constraints at the same time. - Cee McSharpface