Saving Photos for the Web as GIF/PNG
Save GIF/PNG for Web
1
Image → Trim
Removes empty pixels around the artwork — smaller file size.
2
File → Export → Save for Web (Legacy)
Choose GIF or PNG from the Preset menu on the right.
3
Pick a Color Palette
GIF: Perceptual or Adaptive base colors on the actual image; 16 Colors keeps file tiny.
4
Use PNG for Transparency
PNG-24 supports alpha transparency; GIF only supports 1-bit transparency.
Master Photoshop at Noble Desktop
Noble Desktop's Photoshop Bootcamp covers retouching, compositing, color correction, and pro editing.
Discover how to optimize images through GIF or PNG compression in this detailed Photoshop tutorial, guiding you through the process of saving as GIF and comparing GIF to PNG-8 files.

and trim it manually, but there’s a better way. Go to Image > Trim and set the following:
on the left side of the window.