How to resize a picture to a specific file size?

前端 未结 5 885
暗喜
暗喜 2020-12-17 15:12

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 ?

Thanks !

5条回答
  •  北海茫月
    2020-12-17 15:33

    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.

提交回复
热议问题