Get picture width without wait in script

I'm trying to log the width of a picture in my script.
I have the setup below, where I use a script to show the picture.
I have a second script to get the width of the image.

Unless I put a wait command between the two scripts the width will be zero.
I know the wait allows time for the picture to load, which is why the width is returned.
I have concerns about using this approach, as the load time could be different depending on the device, and it feels a bit hacky.

Does any one know if I can replace the wait command with something that detects that the picture has loaded?

Script: $gameScreen.showPicture(1, "SF_PEOPLE1_8", 0, (Graphics.boxWidth),200, 100, 100, 255, 0)
Wait: 5 frames
Script: var picSpriteset = SceneManager._scene._spriteset.children.find(obj => obj.children.length >= 99);
console.log(picSpriteset.children[0].width);
I'm trying to log the width of a picture in my script.
I have the setup below, where I use a script to show the picture.
I have a second script to get the width of the image.

Unless I put a wait command between the two scripts the width will be zero.
I know the wait allows time for the picture to load, which is why the width is returned.
I have concerns about using this approach, as the load time could be different depending on the device, and it feels a bit hacky.

Does any one know if I can replace the wait command with something that detects that the picture has loaded?

Script: $gameScreen.showPicture(1, "SF_PEOPLE1_8", 0, (Graphics.boxWidth),200, 100, 100, 255, 0)
Wait: 5 frames
Script: var picSpriteset = SceneManager._scene._spriteset.children.find(obj => obj.children.length >= 99);
console.log(picSpriteset.children[0].width);
Just another way, probably not the best :
Code:
◆Script: $gameScreen.showPicture(1, "SF_PEOPLE1_8", 0, (Graphics.boxWidth),200, 100, 100, 255, 0)
◆Label:Start
◆If:Script:!SceneManager._scene._spriteset._pictureContainer.children[0].width
  ◆Jump to Label:Start
  ◆
:Else
  ◆Script:let picSpriteset = SceneManager._scene._spriteset.
  :      :  _pictureContainer.children[0].width;
  :      :console.log(picSpriteset);
  ◆
:End

Since you are using show picture 1, it will always be under ._pictureContainer as children[0].

I think a wait time is reasonable, but if you must, this will check until there is a value in the picture container.

Edit: I'll check for another solution when I can get to a computer.

Original thread: https://forums.rpgmakerweb.com/threads/get-picture-width-without-wait-in-script.165201/