Get size of UI Image at runtime

I’m trying to get the true size in pixels of an image at runtime. The image is set to scale automatically. I tried using the rectTransform.size but it only returns the original size of the image before any scaling is applied. How do I get the true size after the automatic scaling is applied ?

Try:

 Image xptoExample;

realWidth = xptoExample.sprite.rect.width;
realHeight = xptoExample.sprite.rect.height;

GetComponent().rect.width

GetComponent().rect.width

GetComponent().rect.height

@a436t4ataf try this, it is working for me Unity 2018 LTS