GraphicConverter is free and can do what you want. My basic technique is to do Save For Web... from Photoshop and then play around with the settings, watching the size and quality. I often start with GIF at perhaps 8 colors and work my way up one at a time (16, 32, 64, etc.), carefully watching my image zoomed-in until I can't see any change when adding more colors (or so little change that it's acceptable). GIF works well for screenshots and some logos where you have only a few colors. Then, you can do the same thing with JPG for continuous-tone images, slowly creeping the compression slider up until you're not noticing any image degradation. I usually prefer GIF over JPG for small images such as avatars, buttons, icons, etc. PNG-24 can provide excellent lossless compression under certain circumstances but its options are limited and generally it's going to be larger than GIF.