- Home /
Getting height and width of images
I need to load images with different sizes. Is there any way to get the height and width of an uploaded file with LoadImageIntoTexture?
Answer by equalsequals · May 02, 2011 at 01:39 AM
LoadImageIntoTexture takes a provided Texture2D and assigns the loaded image to it. From that you can use that Texture2D and use its width and height properties to get that info.
Cheers
==
Thanks for the reply. This is how I use now, but I have to inform in advance the width and height of each image. The ideal would have a method to identify the dimensions from the file, automatically, allowing me to exchange files with others of different sizes. Any suggestions?
What method are you using to load these textures in?
Im using LoadImageIntoTexture and applying on a Cube. I need to know the size of image to set Cube's scale.
I see the LoadImageIntoTexture, so these image files exist on a web server? Why don't you just reflect their dimensions in a file name (ie $$anonymous$$yImage_100x100.png)?
Your answer
![](https://koobas.hobune.stream/wayback/20220613130752im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Is it better to enlarge an image by width/height or by scale? 0 Answers
How to change the Width and Height in the script C#? (New Gui Unity 4.6 beta) 2 Answers
UI Vertical Layout Group with Content Size Fitter, how to set max width? 1 Answer
Object resolution 0 Answers
[UNSOLVED] Get a GameObject width and height in pixels (JS) 3 Answers