You can create an Action to do this if you have a lot of layers to save. Regardless, here's what you do:
- Click on the layer in the layers palette and go under
Layer > Duplicate Layer
(you can also right click for this). - In the dialog box that pops up, look at the bottom where it says Destination and select "New" from the drop down menu. This duplicates the layer in a new document.
- If the background of the new document is transparent, go to
Image > Trim
. Selecttransparent pixels
and trim away top, bottom, left, right.
Click on the layer in the layers palette and go under Layer > Duplicate Layer (you can also right click for this). In the dialog box that pops up, look at the bottom where it says Destination and select "New" from the drop down menu. This duplicates the layer in a new document. If the background of the new document is transparent, go to Image > Trim. Select "transparent pixels" and trim away top, bottom, left, right. If the image had a background color, hide or delete that layer, then follow the step above. Then save the new document and then save for web.