locked
Image size in bytes RRS feed

  • Question

  • I need to get the size of the image in bytes.

    how can i do that?

    it is going to be throught "http://www..." uri



    Monday, December 6, 2010 6:29 AM

Answers

  • Check this thread, it's possible to get it using the Length property.

    http://forums.silverlight.net/forums/p/177990/400829.aspx

    Monday, December 6, 2010 7:18 AM
  • Hi,

    it is going to be throught "http://www..." uri

    I guess you want to download the image and get the image size.

    Here is a possible solution:

    in code behind:

                WebClient wc = new WebClient();
                wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
                Uri ImageUri = new Uri("http://www...");
                wc.OpenReadAsync(ImageUri)

                 

            void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
            {
                System.IO.Stream imageStream = e.Result;

                // Next to do is convert stream to bytes...
            };

    And here is relevant thread about convert stream to bytes

    http://stackoverflow.com/questions/1080442/how-to-convert-an-stream-into-a-byte-in-c

    Hope this helps.

     

    Regards

    Wednesday, December 8, 2010 1:13 AM

All replies

  • Check this thread, it's possible to get it using the Length property.

    http://forums.silverlight.net/forums/p/177990/400829.aspx

    Monday, December 6, 2010 7:18 AM
  • Hi,

    it is going to be throught "http://www..." uri

    I guess you want to download the image and get the image size.

    Here is a possible solution:

    in code behind:

                WebClient wc = new WebClient();
                wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
                Uri ImageUri = new Uri("http://www...");
                wc.OpenReadAsync(ImageUri)

                 

            void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
            {
                System.IO.Stream imageStream = e.Result;

                // Next to do is convert stream to bytes...
            };

    And here is relevant thread about convert stream to bytes

    http://stackoverflow.com/questions/1080442/how-to-convert-an-stream-into-a-byte-in-c

    Hope this helps.

     

    Regards

    Wednesday, December 8, 2010 1:13 AM
  • byte[] imgbuf = e.Result; 

    int len = imgbuf.Length;

     

    Wednesday, December 8, 2010 1:34 AM