当我从mysql、PHP和GD中提取图像时,横幅会出现奇怪的颜色
我想用保存在数据库中的图像制作一个横幅,但当$imagesB从数据库中拍摄图像时,横幅会有一种奇怪的颜色,当我在$imagesB中放置一张照片的链接时,这会保留真实的颜色,我不知道为什么我从数据库中拍摄图像时,图像会采用更绿色的颜色 这是密码当我从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
<?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]你真的需要png吗?我认为这可能与服务器库的性能差有关。你试过jpeg吗?我告诉你这是因为我看到你在使用GD,而我在另存为png时遇到了类似的问题。我真的需要一个png,所以我尝试使用这个库,但我必须安装它并重新启动服务器。但是我在这个库中使用了它,但是这个库称为imagick,所以直接使用imagick应该可以。可能是