Solved

get image width from URI instead of file

Posted on 2010-09-22
2
706 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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 …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

805 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