I have an image file that is a 6k jpg file with a width: 172px and a height: 172px.
I am using the following code, try resizing it to 128 * 128px jpg file:
public static Image ResizeImage(Image img, int width, int height) { var b = new Bitmap(width, height, PixelFormat.Format24bppRgb); using (Graphics g = Graphics.FromImage(b)) { g.DrawImage(img, 0, 0, width, height); } return b; }
This code strangely increased the file size to 50k, can anyone explain why? and how to resize the image to 128 * 128 pixels and keep the size about 6k.
Many thanks.
Dy
c # image-processing
Daoming yang
source share