Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.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

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 - Fatal编程技术网

如何显示用PHP编辑的图像

如何显示用PHP编辑的图像,php,image,Php,Image,我有一个可以显示多段线的图像。我可以完美地显示图像,但当我应用到不使用标题的网站(“内容类型:image/png”);我有麻烦了 我可以在网站上显示用PHP编辑的图像而不仅仅是图像吗 这是我的密码 <?php $img = imagecreatefromjpeg('1967_NL_MAJENEresize.jpg'); //you can change image name $white = imagecolorallocate($img, 255, 255, 255); $red =

我有一个可以显示多段线的图像。我可以完美地显示图像,但当我应用到不使用标题的网站(“内容类型:image/png”);我有麻烦了

我可以在网站上显示用PHP编辑的图像而不仅仅是图像吗

这是我的密码

<?php
$img = imagecreatefromjpeg('1967_NL_MAJENEresize.jpg'); //you can change image name

$white = imagecolorallocate($img, 255, 255, 255);
$red = imagecolorallocate($img, 255, 0, 0);
imagesetthickness($img, 4);

imagefill($img, 0, 0, $white);

imageline($img, 100, 80, 210, 380, $white); //x1, y1, x2, y2
imageline($img, 200, 80, 210, 380, $white); 
imageline($img, 200, 80, 310, 580, $white); 
imagefilledrectangle ($img, (100-5), (80-5), 100+10, 80+10, $red);
imagefilledrectangle ($img, (210-5), (380-5), 210+10, 380+10, $red);
imagefilledrectangle ($img, (200-5), (80-5), 200+10, 80+10, $red);
imagefilledrectangle ($img, (310-5), (580-5), 310+10, 580+10, $red);
header("Content-type: image/png");
imagepng($img);

imagedestroy($img);
?>

您不应在现有内容中包含图像生成代码,而应使用专用脚本使用正确的标题创建图像

使用
行['thumbnail'];?>'>链接到内容中的图像;
废话

您的代码没有使用:-?天哪,我认为像imagecolorallocate、imageline等代码与imagick有关。我真丢脸。所以我再次搜索,发现我使用了GD和Image函数。谢谢您提供的信息。:)
<?php
$imagefile = preg_replace('/[^A-Za-z0-9_\-]/', '_', $_GET['filename']);
$img = imagecreatefromjpeg($imgfile); //you can change image name

$white = imagecolorallocate($img, 255, 255, 255);
$red = imagecolorallocate($img, 255, 0, 0);
imagesetthickness($img, 4);

imagefill($img, 0, 0, $white);

imageline($img, 100, 80, 210, 380, $white); //x1, y1, x2, y2
imageline($img, 200, 80, 210, 380, $white); 
imageline($img, 200, 80, 310, 580, $white); 
imagefilledrectangle ($img, (100-5), (80-5), 100+10, 80+10, $red);
imagefilledrectangle ($img, (210-5), (380-5), 210+10, 380+10, $red);
imagefilledrectangle ($img, (200-5), (80-5), 200+10, 80+10, $red);
imagefilledrectangle ($img, (310-5), (580-5), 310+10, 580+10, $red);
header("Content-type: image/png");
imagepng($img);

imagedestroy($img);
?>
Blah Blah
<img src='generate-image.php?filename=<?= $db->row['thumbnail']; ?>'>;
blah blah