How about the imagejpeg function?
bool imagejpeg ( resource $image [, string $filename [, int $quality ]] )
imagejpeg() creates a JPEG file from the given image .
For help to support BMP format in GD, have a look here, for example.
EDIT: This doesn't support 16 bit images which is correct as the original bitmap specification doesn't support it. In your case, please find out which bit pattern is used to code the color value. I assume it's 5 bits for R and B, 6 bits for G and the order is BGR in this solution (please insert into the code I linked to above):
else if ($bits == 16) {
$gd_scan_line = "";
$j = 0;
while($j < $scan_line_size) {
$byte1 = $scan_line{$j++};
$byte2 = $scan_line{$j++};
$b = chr($byte1 >> 3) * (255 / 31);
$g = (chr($byte1 & 0x07) + chr($byte2 >> 5)) * (255 / 63);
$r = chr($byte2 & 0x1F) * (255 / 31);
$gd_scan_line .= "\x00$r$g$b";
}
Note that I didn't test this code (specifically, I'm not sure about that scaling to 0..255) and it will only work if 5-6-5 bit pattern has been used (well, it will work with others, too, but the colors will be wrong).