说明:原图为png,返回缩略图为jpg格式

$fileName = md5(basename($template) . $url);
$source = '../public/uploads/' . $file . '/invite/' . $time . '/' . $uid . '_' . $fileName . '.png'; //原图

public function handlePic($srcPathName){

    $srcFile = $srcPathName;
    $srcFileExt = strtolower(trim(substr(strrchr($srcFile, '.'), 1)));
    if ($srcFileExt == 'png') {
                        $dstFile = str_replace('.png', '.jpg', $srcPathName);
                        $photoSize = GetImageSize($srcFile);
                        $pw = $photoSize[0];
                        $ph = $photoSize[1];
                        $dstImage = ImageCreateTrueColor($pw, $ph);
                        imagecolorallocate($dstImage, 255, 255, 255);
                        //读取图片
                        $srcImage = ImageCreateFromPNG($srcFile);
                        //合拼图片
                        imagecopyresampled($dstImage, $srcImage, 0, 0, 0, 0, $pw, $ph, $pw, $ph);
                        imagejpeg($dstImage, $dstFile, 70);
                        imagedestroy($srcImage);
    }

}