admin管理员组

文章数量:1393035

I know that when you save an Image you should provide a codec and encoding parameters, otherwise it might be saved with compression and etc.

So I can't understand why the following two code produces two different results:

System.Drawing.Image img1 = System.Drawing.Image.FromFile(imgPath);
System.Drawing.Image img2 = System.Drawing.Image.FromFile(imgPath);
img2.RotateFlip(RotateFlipType.RotateNoneFlipX);

var codec = ImageCodecInfo.GetImageEncoders().First(x => x.CodecName.Contains("Built-in PNG Codec"));
EncoderParameters ep = new EncoderParameters();
ep.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, (long)100);

img1.Save(@"C:\test1.png", codec, ep);
img2.Save(@"C:\test2.png", codec, ep);

The resulting test1.png and test2.png are of different size and compression. Why is that?

本文标签: cRotating image reduces sizedespite codec and encoding parametersStack Overflow