Did you use the tab "Uploaded images" in the library? If yes, please try something else instead: Either add images with the web image search or just drag and drop the image file from your desktop into the space in your browser window. If you add images like that, you can get their ID like with any other object:

I hope this will help you complete your project. By the way, we also have a special forum for scripting related questions. You can find it here: https://groups.google.com/forum/#!forum/cospaces-scripting