Search code examples
androidiphonetitaniumtitanium-mobile

get image hight and with in Titanium


I need to get the hight and width of an image from a server that i need to show directly to the user.

so e have tried to create a imageView and put the image in it so i could read the hight and width of the imageView

var image = Ti.UI.createImageView({
                image : //host Site,
                width : "auto",
                height : "auto"
            });

var hight = image.height;
var width = image.width;

but it returns always hight = auto and width = auto.

how can i get the height and width like fro example hight = 630 and width = 320?


Solution

  • I figured out how to get the hight and width of an image

     var image = Ti.UI.createImageView({
                    image : //host Site,
                    width : "auto",
                    height : "auto"
                });
    
    var hight = image.toBlob().height;
    var width = image.toBlob().width;
    

    i hade only to add toBolob() where i'm trying to get the height and width