Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php创建具有唯一序列号的多个图像文件时出错_Php_Image_Header - Fatal编程技术网

php创建具有唯一序列号的多个图像文件时出错

php创建具有唯一序列号的多个图像文件时出错,php,image,header,Php,Image,Header,我有一个功能,可以创建多个图像,每个图像上都有唯一的序列号。问题在于,它会在浏览器上创建一个小正方形,而在保存回仪表板后不会重定向浏览器 header("Content-type: image/png"); $imgPath = 'background1.png'; $string = $serialNumber; $directory = "serial_image/".$string.".png"; $image = imagecreatefrompng($imgPath); $color

我有一个功能,可以创建多个图像,每个图像上都有唯一的序列号。问题在于,它会在浏览器上创建一个小正方形,而在保存回仪表板后不会重定向浏览器

header("Content-type: image/png");
$imgPath = 'background1.png';
$string = $serialNumber;
$directory = "serial_image/".$string.".png";
$image = imagecreatefrompng($imgPath);
$color = imagecolorallocate($image, 0, 0, 0);
$font = 'arial.ttf';
$fontSize = 13;
$x = 20;
$y = 212;
imagettftext($image, $fontSize, 0, $x, $y, $color, $font, $string);

imagepng($image, $directory);
我调用该函数创建10个图像,每个图像具有唯一的序列号。它们已创建,但随后浏览器停止并仅显示此正方形

我试过
ob\u start()
ob\u flush()
,但运气不好

我认为这是头球问题

有人能帮我做这个吗