Get all image IDs from the Media Library

From my understanding I can’t get the image IDs directly from
wordpress. I have to first get their URLs and then extract their IDs.
If there is a more efficient way to do this please let me know.

I’m not sure I follow you there, but did you try this:

$ids = get_posts( 
    array(
        'post_type'      => 'attachment', 
        'post_mime_type' => 'image', 
        'post_status'    => 'inherit', 
        'posts_per_page' => -1,
        'fields'         => 'ids',
    ) 
);
$images = array();
foreach ( $ids as $id )
    $images[]= $id;

print_r( $images );

where $images should contain the ID’s of all the images.

For example:

Array
(
    [0] => 3299
    [1] => 3298
    [2] => 3297
    [3] => 3266
    [4] => 3265
    [5] => 3260
    [6] => 3259
    [7] => 3258
    [8] => 3257
)