Constrain image heigh to vertical measurement device

Is there any way to constrain the length of an image to vertical measurement device (tablets, phones…)?
I work with narrow portrait ratio image (400x1200px) and I would like to show the full image regardless the device position (portrait or landscape).
Comments would be appreciated.