Png compression

  • Thread starter Thread starter Franz
  • Start date Start date
F

Franz

I want to ask about the png compression for Bitmap.Save
Here are the case :

Jpg (768 x 576 , 301KB) => Jpg (384 x 288, 22KB)
Jpg (768 x 576 , 301KB) => Png (384 x 288, 311KB)

Is the compression of png worst than that of jpg?

Here are the code :

Image image = Bitmap.FromFile(filePath);

int newWidth = (int)(percentage * image.Width);
int newHeight = (int)(percentage * image.Height);

Rectangle rectDest = new Rectangle(0, 0, newWidth, newHeight);
Bitmap bitmap = new Bitmap(rectDest.Width, rectDest.Height);
Graphics g = Graphics.FromImage(bitmap);
g.DrawImage(image, rectDest, 0, 0, image.Width, image.Height,
GraphicsUnit.Pixel);
image.Dispose();

bitmap.Save(filePath, format);
bitmap.Dispose();
 
If memory serves, png is a lossless compression model. Because its lossless
it will almost always result in files that are larger than the equivilent
jpeg, which is a lossy compression system(that is, it throws data you don't
need away).

So, the compression is different and each format has a different purpose. If
you are looking into lossless compression for images go with png, if you are
looking for best quality\size ratio, jpeg will probably do you well.
 
Back
Top