The specific code is as follows. The first part is the noodle code, and the second part is a function that is blocked for repeated use. Pay attention to the comments in the previous function. Because I don’t want to make too many parameters for this function, some configuration items are written in the function.
<?php /* $dst_path = ""; $z_path = "./"; $f_path = "./"; $wp_path = ""; $dst = @imagecreatefromjpeg($dst_path); $im_z = imagecreatefromjpeg($z_path);//Return image identifier $im_f = imagecreatefromjpeg($f_path);//Return image identifier $im_wp = imagecreatefrommpng($wp_path);//Return image identifier list($z_width,$z_height,$z_type,$z_attr)=getimagesize($z_path); list($f_width,$f_height,$f_type,$f_attr)=getimagesize($f_path); //imagecopyresized ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) imagecopyresized($dst,$im_z,10,10,0,0,580,360,$z_width,$z_height);//Return boolean value imagecopyresized($dst,$im_f,10,380,0,0,580,360,$f_width,$f_height);//Return boolean value imagecopyresized($dst,$im_wp,10,320,0,0,600,165,600,165);//Return Boolean value imagejpeg($dst, './'.time().".jpg"); imagedestroy($dst); echo 'ok'; */ $path_z = "./"; $path_f = "./"; echo makeSfzImage($path_z, $path_f); /** * Generate a picture and combine it with a watermark through the front and background photos of your ID card. * You need to prepare a blank picture and a watermark picture, put it in the /webui/member/images/ directory, and create the sfz directory in the Upload directory. * @param string $path_z, front * @param string $path_f, back * @return string, the generated photo path, note that the returned format is: ./Upload/sfz/ * */ function makeSfzImage($path_z, $path_f){ /* * The previous configuration information */ $path_blank = realpath('./webui/member/images/'); //Blank picture address, used to base $path_wp = realpath('./webui/member/images/'); //Watermark picture address $path_save = './Upload/sfz/'; //Save path //Import four pictures $im_blank = @imagecreatefromjpeg($path_blank); $im_z = @imagecreatefromjpeg($path_z);//Return image identifier $im_f = @imagecreatefromjpeg($path_f);//Return image identifier $im_wp = @imagecreatefrompng($path_wp);//Return image identifier //Get the width and height of the positive and negative pictures list($z_width,$z_height,$z_type,$z_attr)=getimagesize($path_z); list($f_width,$f_height,$f_type,$f_attr)=getimagesize($path_f); //imagecopyresized ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) //combination imagecopyresized($im_blank,$im_z,10,10,0,0,580,360,$z_width,$z_height);//Return Boolean value imagecopyresized($im_blank,$im_f,10,380,0,0,580,360,$f_width,$f_height);//Return Boolean value imagecopyresized($im_blank,$im_wp,10,320,0,0,600,165,600,165);//Return Boolean value //generate $path_file = $path_save.time().".jpg"; imagejpeg($im_blank, $path_file); imagedestroy($im_blank); return $path_file; } ?>
The first few are the image configuration parameters, you can modify them as needed.