How to create CSS sprites with Adobe Photoshop
Install the following script from Github:
wget https://raw.github.com/euskadi31/Photoshop-CSS-Sprite/master/PSprite.jsx
mv PSprite.jsx /Applications/Adobe\ Photoshop\ */Presets/Scripts
Then:
* create some layers in your PSD file
* name your layers
* select File->Scripts->PScript
* open