开发者

URI formats are not supported for properties height and width of image

I am tryin开发者_JAVA技巧g to access height and width of an System.Drawing.Image.

Image image = Image.FromFile(PostedImage.ImageUrl.ToString());
int ActualWidth = image.Width;
int ActualHeight = image.Height;

I am getting error

URI formats are not supported.

How can this be done?


You have to pass a path to a local file or one on a network drive.

If the string you give it is to a web resources, you have to first download it.


This means that you cannot sent a URL to Image.FromFile() You must pass a local path on disk.

To remedy this:

  • saving your image to a location on disk
  • load your image into a Stream of some kind, and use Image.FromStream()


my guess is that FromFile works on local files only. i would fetch the file using WebRequest and then create Image from stream.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜