I finally figured it out myself.
As I need to run my function after the DB link was completed, I used the following action hook;
add_action('shutdown', 'runImageFunctions');
That means, I don’t know if it means any bad things, that when the whole page is loaded and complete, even the DB link that creates the “_wp_attachment_metadata” row is complete.
I can’t bother to explain in detail.. But that’s the story!