How to get the width and height of a image by its given URL?

Discussion in 'ASP .Net' started by =?Utf-8?B?TGFzZXIgTHU=?=, Jun 1, 2004.

  1. I want to get the pixel size of a image file, which is specified by its URL. The problem is how to load the image file by a URL, and then how to get its size? I'm looking for any useful advices.
     
    =?Utf-8?B?TGFzZXIgTHU=?=, Jun 1, 2004
    #1
    1. Advertisements

  2. =?Utf-8?B?TGFzZXIgTHU=?=

    Scott Allen Guest

    ..NET makes this pretty easy using classes from the System.Drawing and
    System.NET namespaces:

    string imageUrl =
    "http://msdn.microsoft.com/nodehomes/graphics/80x60/aspnet.jpg";

    WebRequest request = WebRequest.Create(imageUrl);
    WebResponse response = request.GetResponse();
    Image image = Image.FromStream(response.GetResponseStream());

    Console.WriteLine("Image size: {0}x{1}",
    image.Width, image.Height);

    HTH,

    --
    Scott
    http://www.OdeToCode.com


    On Tue, 1 Jun 2004 05:11:02 -0700, "Laser Lu"
    <> wrote:

    >I want to get the pixel size of a image file, which is specified by its URL. The problem is how to load the image file by a URL, and then how to get its size? I'm looking for any useful advices.
     
    Scott Allen, Jun 1, 2004
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sean Jorden
    Replies:
    1
    Views:
    763
    laurie
    Aug 19, 2003
  2. Lois
    Replies:
    1
    Views:
    4,179
    Ryan Stewart
    Dec 27, 2004
  3. Apple
    Replies:
    3
    Views:
    452
    Apple
    Aug 1, 2005
  4. Bernd Meier
    Replies:
    6
    Views:
    719
    GTalbot
    Jan 14, 2008
  5. Nancy Drew

    pure asp way to get image width and height

    Nancy Drew, Oct 28, 2004, in forum: ASP General
    Replies:
    7
    Views:
    482
  6. thunk
    Replies:
    1
    Views:
    595
    thunk
    Mar 30, 2010
  7. thunk
    Replies:
    0
    Views:
    756
    thunk
    Apr 1, 2010
  8. Ben
    Replies:
    9
    Views:
    552
    jdalton
    May 2, 2008
Loading...