Access to private property

hello ,

i want to access to a private property ( _imageHeight ) and (_imageWidth) to use this values before uploading picture.

any idea ??
thanks for help :slight_smile:

You can simply access it like any other properties but we won t guarantee any back compatibility and we might change it in the future. Are you sure there are no corresponding public ?

i can’t access to private property :
“error TS2341: Property ‘_imageHeight’ is private and only accessible within class ‘Image’.”

other corresponding public cant find to get image height and width :confused:

Maybe image.width or image.widthInPixels ? Its gui image? Or texture?

image.width always = 100% and imageInPixels always = 0 :confused:

This is a message from typescript preventing the “use at your own risk issues” but you can cast as any to access it or to a type containing them as public.

But be careful we are not supporting those cases, I can t emphasize this part enough :slight_smile:

Its correct. If you use width in % you cant use width in pixels because you use %. In your case 100% from what container? Maybe you can set container width in pixels and get size from container? Or calculate and set image width in pixels?

Normally, you should get the value you want through .domImage.width and .domImage.height as it is how _imageWidth and _imageHeight are set in the first place.

how can i use cast with _imageHeight ?

.domImage.heigh always return 0 as value

Maybe playground from you help us?

thanks for your time

@sebavan @kvasss @Evgeni_Popov :

So what are you trying to achieve? except for measurement for the sake of measurement.
I use onImageLoadedObservable for wait loading image and after this take naturalWidth and naturalHeight from loaded image. You problem is try get size before image loaded.


As @kvasss says, use onImageLoadedObservable to get the width/height of the picture. Accessing _imageWidth / _imageHeight won’t help you in your PG, they are both undefined.


thanks a lot @kvasss :DD