Solved

get image width from URI instead of file

Posted on 2010-09-22
2
709 Views
Last Modified: 2012-05-10
how can i get an image's height and width in the code behind (using vb) when the source of the image is a URI?

i can't use the image.fromfile() because it needs a root directory structure.
0
Comment
Question by:attipa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
Jesse Houwing earned 500 total points
ID: 33741922
You can use the WebClient to download the image and use the Image.FromStream constructor:

 string url = "http://www.google.com/logo.png";
            WebClient wc = new WebClient();
            Image img =  Image.FromStream(new MemoryStream(wc.DownloadData(url)));

0
 
LVL 15

Expert Comment

by:oobayly
ID: 33742071
As it's the browser that will be fetching the image, you need to use something like the System.Net.WebClient to download the image from the URI. You can then create am image from a stream containing the bytes, and fetch the size from it. I'd cache the size so that you don't have to do this every time the page is loaded.
Of course, if the image is on the local server, then just use Server.MapPath
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question