如何调整图片到一个特定的文件的大小?大小、文件、图片

2023-09-07 09:59:28 作者:请别靠近我

我想调整画面,以特定的文件大小。例如,不超过200KB更多。 什么是用C#.NET实现这一目标的最佳方法?

I would like to resize a picture to a specific file size. For example, no more than 200KB. What is the best approach to achieve this with C# .NET ?

谢谢!

推荐答案

如果你仔细想想,你是不会知道的图像文件大小它的调整之后。所以,你要么得进行尝试的连续迭代​​事后比较文件的大小,或者你可以改变你的约束图像限制为一组特定的高度和宽度尺寸。

If you think about it, you aren't going to know the filesize of the image until after it's resized. So you've either got to perform a successive iteration of attempts and compare the file sizes afterwards or you could change your constraints to restrict images to a particular set of height and width dimensions.