After much trial and error and gnashing of teeth I finally figured out how to composite a png with an 8-bit alpha onto a jpg. This was not obvious to me so I thought I'd share. Hope it helps.
I'm using this to create a framed thumbnail image:
<?php
$frame = imagecreatefrompng('path/to/frame.png');
$thumb = imagecreatefromjpeg('path/to/thumbnail.jpg');
$width = imagesx( $frame );
$height = imagesy( $frame );
$img=imagecreatetruecolor( $width, $height );
imagealphablending($img, true);
$transparent = imagecolorallocatealpha( $img, 0, 0, 0, 127 );
imagefill( $img, 0, 0, $transparent );
imagecopyresampled($img,$thumb,32,30,0,0, 130, 100, imagesx( $thumb ), imagesy( $thumb ) );
imagecopyresampled($img,$frame,0,0,0,0, $width,$height,$width,$height);
imagealphablending($img, false);
imagesavealpha($img,true);
header('Content-type: image/png');
imagepng( $img );
imagedestroy($img);
exit;
?>