I'm creating a VS Code extension and I need to get the properties of image files, only the dimensions/size of the image file using JS(I.e., 1200 × 627). Like the piece of information such as the “Size” that shows in the bottom right corner of the status bar in VS Code when an image file is opened.
I have to do this with either a CDN link of the image, like
https://www.cloudflare.com/static/d2cf82ac895f472c6d208cdccf4e722e/cdn-lc.png or path to the local disk's directory like
I:\Projects\VSCode Extensions\test\New folder\desktop-banner-web.jpg without loading/previewing the image anywhere. Just the retrieval of natural height & width of the image file would suffice for calculations and displaying the result(ratio) to the user.
I'm currently getting the URL or the path to the image using Selection (Have to get it without entering the link or path manually)
So it could read the image file and provide me with the size/dims, but since VS Code doesn't expose the DOM, I couldn't use JS to find the dimensions, which can be done easily.
I tried to get the size/dims using the stat method under FileSystemProvider in the VS Code API Doc but to no avail.
Are there any possibilities of achieving this without going over to the Webview?
If someone could provide me with a working code using only JavaScript to get the height & width of any image file in any way of a CDN link or a path, I would greatly appreciate it as I couldn't find anything near this in my research. Thanks in advance.