You didn't say which version of WordPress. If it's 2.5, view the source of a page and you'll see the images already have a few classes. One looks like "wp-image-nn" where nn is (guessing here...) the id of the image in your posts table. So you don't have to do a thing! Unless you wanted them to have a different naming format.
Take a peek at the posts table in your database, you'll find that images uploaded into a post are listed in there, they just have a different type. You could write a query to get them, or poke around in the wp-includes directory for the code that does this to display them in your posts.
BUT, that said, since you mentioned css ids, I am assuming you'll start by displaying them all in your post in the HTML.