Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.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
当我从mysql、PHP和GD中提取图像时,横幅会出现奇怪的颜色_Php_Mysql_Php Gd - Fatal编程技术网

当我从mysql、PHP和GD中提取图像时,横幅会出现奇怪的颜色

当我从mysql、PHP和GD中提取图像时,横幅会出现奇怪的颜色,php,mysql,php-gd,Php,Mysql,Php Gd,我想用保存在数据库中的图像制作一个横幅,但当$imagesB从数据库中拍摄图像时,横幅会有一种奇怪的颜色,当我在$imagesB中放置一张照片的链接时,这会保留真实的颜色,我不知道为什么我从数据库中拍摄图像时,图像会采用更绿色的颜色 这是密码 <?php require('db.php'); session_start(); $w = 480*10; $h = 270*5; header("Content-Type: image/png"); $im = i

我想用保存在数据库中的图像制作一个横幅,但当$imagesB从数据库中拍摄图像时,横幅会有一种奇怪的颜色,当我在$imagesB中放置一张照片的链接时,这会保留真实的颜色,我不知道为什么我从数据库中拍摄图像时,图像会采用更绿色的颜色

这是密码

<?php 
  require('db.php');
  session_start();

  $w = 480*10;
  $h = 270*5;

  header("Content-Type: image/png");

  $im = imagecreate($w, $h) or die("Cannot initialize GD extension");
  $canvas = imagecolorallocate($im, 245, 245, 245);

  $sql = "SELECT * FROM Cinema";
  $result = mysqli_query($mysqli, $sql);
  $results = array();

  if (mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)) {
      $results[] = $row['Coperta'];
    }
  }

  for($i=0;$i<10;$i++){
  // here i also tried to obtain the photos directly from mysql with $imagesB ="http://projects.rusticwoodromania.com/uploads/".$row['Coperta']; but the same results
    $imagesB = "http://projects.rusticwoodromania.com/uploads/".$results[$i];
  // when this link it's "http://projects.rusticwoodromania.com/uploads/1535026678_545047747.png"; the image look normal not with this kind of green


    $imgB = imagecreatefrompng($imagesB);
    $a = $i*480;

    for($j=0;$j<5;$j++){
      $b = $j*270;
      imagecopyresampled($im, $imgB, $a, $b, 0, 0, 480, 270, 480, 270);
    }
  }

  imagepng($im);

?>

尝试使用
imagecolorallocate($im,0,0,0)$imagesB=”http://projects.rusticwoodromania.com/uploads/“$行['Coperta']
$imagesB=”http://projects.rusticwoodromania.com/uploads/“$results[$i]