Loading an image, how to know width and height, how?

Is there a way to know the width and height of an image? I need to load an image and to kno if it is in landscape mode or not… [import]uid: 113117 topic_id: 29592 reply_id: 329592[/import]

Yes.

imageName.width
imageName.height
or with a var

local iw, ih = imageName.width, imageName.height [import]uid: 18246 topic_id: 29592 reply_id: 118826[/import]

pic = display.newImage("somephoto.jpg")  
if pic.width \> pic.height then  
 print("Landscape")  
else  
 print("Portrait")  
end  

Of course if you’re using display.newImageRect() you have to provide the width and height so you should know that in advance, but the same code will work.
[import]uid: 19626 topic_id: 29592 reply_id: 118860[/import]

Hi Robmiracle,

Just a little problem, if the width == height (i’ve some pict like this)
you must specify the way you want.

:wink:
[import]uid: 18246 topic_id: 29592 reply_id: 118863[/import]

If you have a square image, in most usages, it doesn’t matter if you treat it as a landscape or a portrait, but if you want to be picky:

pic = display.newImage("somephoto.jpg") if pic.width \> pic.height then print("Landscape") elseif pic.width \< pick.height then print("Portrait") else print("Square") end [import]uid: 19626 topic_id: 29592 reply_id: 118867[/import]

Well,

Thanks ! [import]uid: 18246 topic_id: 29592 reply_id: 118868[/import]