0

I'm trying to save the image as follows:

var file = Image.FromFile(@"D:\front.png");
file.Save(@"D:\front_save.png");

Size of the saved imeage increases almost twice the size of original one. How do I save the image so it's completely the same as original image?

Image Link

Community
  • 1
  • 1
Evgeny Belov
  • 308
  • 4
  • 12

1 Answers1

0

Unfortunately, .NET doesn't expose any way to control the parameters that are applied as part of the PNG compression. Since PNG is a lossless format, the two images are "the same", they're just stored differently. What ever tool saved the original image must use different compression parameters than the default .NET PNG compression defaults, resulting in an optimized file size. When you save from .NET, the default compression parameters result in a larger, non-optimized, file size.

The answer to this question lists some third party libraries that you could use for PNG optimization. If you're not concerned about losing information, you could save the image as a jpeg.

  • I don't have enough rep to comment in the original question. But I just realized that @mjwills solution of using File.Copy() would do exactly what you want as long as you don't need access to the Image in C#. – Sterling C. Aug 29 '18 at 12:19