I am using this code to load two images and find their dimensions in pixels: img.jpg and imgFlipped.jpg.
Texture2D img = new Texture2D(1, 1); byte tmpBytes = File.ReadAllBytes("Assets/Resources/Images/img.jpg"); img.LoadImage(tmpBytes); Debug.Log("img:" + img.width + "--" + img.height); Texture2D imgFlipped = new Texture2D(1, 1); byte tmpBytesFlipped = File.ReadAllBytes("Assets/Resources/Images/imgFlipped.jpg"); imgFlipped.LoadImage(tmpBytesFlipped); Debug.Log("imgFilpped:" + imgFlipped.width + "--" + imgFlipped.height);
imgFlipped is just as the name says; img flipped 90 degrees.
The resolution of img is 2048 x 1152 which means that imgFlipped should have a resolution of 1152 x 2048. However the output in the console is saying otherwise. It keeps the same resolution.
The goal was actually just to find pixel size of the texture I am loading.
PS: even when visualizing imgFlipped.jpg, it flips and gets visualized as img.jpg
- What is going wrong here? Does ImageLoad consider the largest dimension as width ?
- Is there another way to get the real dimensions of an image on the disk ?