Loaded sprite starts with 0 x 0 dimensions?

I'm trying to load a sprite sheet using ImageManager.loadCharacter so I can check the image's dimensions, but the first time I try to load the image, the resulting bitmap object has a .height and .width of 0. This happens for all the other resources the game loads, the first time- if it tries to load the same image again (Probably because it's cached), suddenly the width and height are right, and clearly they work when the game needs to use them.


When does it update the dimensions, and does anyone know if there's steps to either a) wait until that's complete, or b) force it to find the actual dimensions?


Thanks in advance!
Loading is asynchronous, so you are never going to get the dimensions on the line after you call the load command.  You either have to just allocate a bitmap and let it populate when the image is loaded (check within the update to see if the values are non-zero) or add a callback to happen after the load is complete.  Yanfly's save plugin has an example of how to do that.  Or change it to load synchronously, which is an option if your game is never going to be run from a browser and download its resources at runtime.
I always forget these are meant to be usable in a browser. That'd explain why it uses so asynchronous calls.

Original thread: https://forums.rpgmakerweb.com/threads/loaded-sprite-starts-with-0-x-0-dimensions.73332/