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. Advertising

  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. Advertising

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. Lois
    Replies:
    1
    Views:
    3,182
    Ryan Stewart
    Dec 27, 2004
  2. Apple
    Replies:
    3
    Views:
    292
    Apple
    Aug 1, 2005
  3. Bernd Meier
    Replies:
    6
    Views:
    499
    GTalbot
    Jan 14, 2008
  4. Nancy Drew

    pure asp way to get image width and height

    Nancy Drew, Oct 28, 2004, in forum: ASP General
    Replies:
    7
    Views:
    311
  5. Ben
    Replies:
    9
    Views:
    377
    jdalton
    May 2, 2008
Loading...

Share This Page