To get right picture dimension from photo loaded from the Photo Library?

Hello,

Did someone found a way to understand picture orientation on i-device?

I load pictures from the Photo Library on ipad but loading portrait or horizontal picture, the texture.width and texture.height always return 960 x 720.

Also tried with the Etcetera plugins function : EtceteraBinding.getImageSize(imagePath) , but same, always 960 x 720.

On Mac, if I load a picture, the width and height value are always right, then very easy to understand if the picture is portrait or landscape.

Thanks!

It seems the Xcode API allows the user to get the right picture orientation :

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImage_Class/Reference/Reference.html

UIImageOrientation
Specifies the possible orientations of an image.

typedef enum {
UIImageOrientationUp,
UIImageOrientationDown, // 180 deg rotation
UIImageOrientationLeft, // 90 deg CCW
UIImageOrientationRight, // 90 deg CW
UIImageOrientationUpMirrored, // as above but image mirrored along
// other axis. horizontal flip
UIImageOrientationDownMirrored, // horizontal flip
UIImageOrientationLeftMirrored, // vertical flip
UIImageOrientationRightMirrored, // vertical flip
} UIImageOrientation;
Constants

But nothing on Unity API ether Prime31 or other plug ins…

Didn’t someone try this before?

I am able to pay to get some help :

http://forum.unity3d.com/threads/164029-Unity-plugin-need-to-access-to-the-Xcode-UIImageOrientation-function.

:stuck_out_tongue:

Small update to this topic.

I found out the issue only occur on older device.
Below the list :

if (iPhoneSettings.generation == iPhoneGeneration.iPad1Gen ||
			iPhoneSettings.generation == iPhoneGeneration.iPad2Gen ||
			iPhoneSettings.generation == iPhoneGeneration.iPhone3G ||
			iPhoneSettings.generation == iPhoneGeneration.iPhone3GS ||
			iPhoneSettings.generation == iPhoneGeneration.iPodTouch1Gen ||
			iPhoneSettings.generation == iPhoneGeneration.iPodTouch2Gen ||
			iPhoneSettings.generation == iPhoneGeneration.iPodTouch3Gen ||
			iPhoneSettings.generation == iPhoneGeneration.iPodTouch4Gen)
		{
}

In my code I just added a rotate button into the app to be sure user can set the right orientation on those devices.

Other devices return the right width and height then easy to define the picture orientation.