I perform a query within the wordpress db to be able to retrieve the ids of images because of the gallery Id they fit in with.for your I've produced the next function.

function nggfirstImage(){

global $wpdb;
    $firstImage = $wpdb->get_var("SELECT pid FROM $wpdb->wp_ngg_pictures WHERE galleryid=1 AND  sortorder=1");
    echo $firstImage;

}

However I obtain the following error..

[You possess an error inside your SQL syntax look into the manual that matches your MySQL server version for the best syntax to make use of near 'WHERE galleryid=1 AND sortorder=1' at line 1] Choose pid Where galleryid='1' AND sortorder='1'

Any ideas?

4nt0n