如何将C#中的图像调整为某个硬盘大小? [英] How to resize an image in C# to a certain hard-disk size?

查看:107
本文介绍了如何将C#中的图像调整为某个硬盘大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将C#中的图像调整为某个硬盘大小,如2MiB?有没有比试验和错误更好的方法(当然,即使它是近似的)。

How to resize an image an image in C# to a certain hard-disk size, like 2MiB? Is there a better way than trial and error (even if it's approximate, of course).

尝试在网络上找到解决方案时要搜索的任何特定关键字?

Any particular keywords to search for when trying to find the solution on the web?

推荐答案

这取决于你愿意改变什么

It depends on what you are willing to change


  1. 缩小图像尺寸

  2. 更改图像格式

  3. 如果格式支持有损压缩,请减少质量

  4. 如果您要存储不需要的元数据,请将其删除

  5. 减少颜色数(以及每个像素的位数) )

  6. 更改为调色板格式

  7. 更改为调色板格式并减少颜色

  1. Make the size of the image smaller
  2. Change the format of the image
  3. If the format supports a lossy compression, decrease the quality
  4. If you are storing meta-data that you don't need, remove it
  5. Reduce the number of colors (and bits per pixel)
  6. Change to a paletted format
  7. Change to a paletted format and reduce the colors

很难猜出最终的磁盘大小是多少,但如果你知道一个起点,你可以得到一个很好的估计。减小尺寸可能是成比例的,减少每像素的比特也可能是成比例的。

It's hard to guess what the final disk size will be, but if you know a starting point you can get a pretty good estimate. Reducing the size will probably be proportional, reducing the bits per pixel will also likely be proportional.

如果您更改格式,压缩或质量,那实际上只是猜测 - 在很大程度上取决于图像内容。你可以通过在与你认为你将看到的相匹配的图像语料库中尝试获得一个很好的范围。

If you change the format, compression or quality, it's really just a guess -- depends highly on the image content. You could probably get a good range by trying it on a corpus of images that matches what you think you'll be seeing.

这篇关于如何将C#中的图像调整为某个硬盘大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆