Gallery Image Numbers?

This should do it:

global $post;
$ancestors = get_post_ancestors($post->ID);

$photos = get_children(array(
  'post_mime_type' => 'image', 
  'post_parent'    => array_shift($ancestors),
));

$index = 0;
foreach($photos as $photo){
  $index++;
  if($photo->ID === $post->ID) break;
}

printf('%d out of %d', $index, count($photos));

error code: 523