The ID is the order of discovery from the file system. I don't know how Gallery does it, but Zenphoto is entirely file system based. If you uploads folders with images or folders directly via FTP and once visiting the first time they are recognized and added.
If you remove them via FTP Zenphoto will remove them as soon as the album is visited. Both counts for front and back end.
Some info on the caching and discovery process:
http://www.zenphoto.org/news/caching