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

jei2mxaa  于 2021-06-20  发布在  Mysql
关注(0)|答案(0)|浏览(146)

我想用保存在数据库中的图像制作一个横幅,但是当**$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);

?>

1.与“绿色”形象挂钩
2.与正常图像链接

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题