有没有便宜的方法来获取图片的尺寸(jpg,png,...)?最好是只使用标准类库(因为托管限制)来实现这一点。我知道读取图像头部并自己解析它应该相对容易,但看起来像这样的东西应该已经存在了。此外,我还验证了以下代码读取了整个图像(我不想要这样的图像):
using System;
using System.Drawing;
namespace Test
{
class Program
{
static void Main(string[] args)
{
Image img = new Bitmap("test.png");
System.Console.WriteLine(img.Width + " x " + img.Height);
}
}
}
https://stackoverflow.com/questions/111345
复制相似问题