我如何可靠地获取在.NET中的图像尺寸,而无需加载的形象呢? [英] How do I reliably get an image dimensions in .NET without loading the image?

查看:167
本文介绍了我如何可靠地获取在.NET中的图像尺寸,而无需加载的形象呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何获取图像的大小(X,Y)

I know how to get the size (x,y) of an image

Image.FromFile("cat.jpg").Size

但需要从内存中加载图像。

BUT that requires loading the image from memory.

当我查看Windows资源管理器中的图像它显示我的尺寸。

When I view the images in Windows Explorer it shows me the size.

  • 如何访问尺寸?
  • 是可靠的所有图像?请问Windows资源管理器需要有看到的图像首次为大小可用。我不想上传到服务器,没有可用的元数据,我在Internet Explorer中加载它。

编辑:我改变了从规模到维的主题,以澄清我想它的大小

I changed the subject from 'size' to 'dimensions' to clarify which size i wanted.

推荐答案

您可以只使用的 Image.FromStream(流,布尔,布尔) 与假第2和第3个参数,以避免加载文件到内存中。

You can just use Image.FromStream(Stream, bool, bool) with "false" 2nd and 3rd parameter to avoid loading file into memory.

这篇关于我如何可靠地获取在.NET中的图像尺寸,而无需加载的形象呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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