Can someone explain to me why writing the stream from a PNG image back into another PNG file increases the size of the final output?
Original file: size (28.6 KB), size on disk (32.0 KB)
Output file: size (32.1 KB), size on disk (36.0 KB).
The code for doing this operation is pretty straight forward:
private void button1_Click(object sender, EventArgs e)
{
var result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
var file = openFileDialog1.FileName;
var stream = new FileStream(file, FileMode.Open);
var newImg = Image.FromStream(stream);
newImg.Save("newPNG.png", ImageFormat.Png);
stream.Close();
}
}
How can I avoid this? I would like the final image to have the exact same size as the original one.
LE: I uploaded the original image if anyone wants to try it out. cat image