public function getmergeQR($file,$card_id){
$path_1 = 'http://**********/uploads/bade8.png';
$context = stream_context_create(array(
'http' => array(
'timeout' => 30
) ));
ini_set("user_agent","Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)");
$path_file = file_get_contents($path_1, 0, $context);
$path_2 = "http://***{$file}";
$image_1 = imagecreatefromstring($path_file);
$image_2 = imagecreatefromjpeg($path_2);
$image_3 = imageCreatetruecolor(imagesx($image_1),imagesy($image_1));
$color = imagecolorallocate($image_3, 255, 255, 255);
imagefill($image_3, 0, 0, $color);
imageColorTransparent($image_3, $color);
imagecopyresampled($image_3, $image_1, 0, 0, 0, 0, imagesx($image_1), imagesy($image_1), imagesx($image_1), imagesy($image_1));
imagecopymerge($image_3, $image_2, 0, 0, 0, 0, imagesx($image_2), imagesy($image_2), 100);
$baseUrl = DIRECTORY_SEPARATOR .implode(DIRECTORY_SEPARATOR, ['mergewechat',date('Y-m-d',time())]). DIRECTORY_SEPARATOR;
$path = $_SERVER['DOCUMENT_ROOT'].'/uploads'.$baseUrl;
if(!is_dir($path)){
mkdir($path, 0777, true);
}
$image_file = $path.$card_id.'.png';
imagepng($image_3,$image_file);
return '/uploads'.$baseUrl.$card_id.'.png';
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-46051.html