我一直在努力使用 PHP 将样本保存为图像,我在这方面取得了先机,到目前为止,它正在保存第一种颜色、最后一种颜色和黑色 - 但迭代三个块的最后一种颜色。
<?php
$colours = $_GET['c'];
$swatches = explode("|", $colours);
// Create image
$im = imagecreatetruecolor(120, 30);
foreach ($swatches as $key => $rgb_set)
{
if ($rgb_set=="") break;
list($r, $g, $b) = explode(",", $rgb_set);
$x_pos = (24 * $key);
$swatch = imagecolorallocate($im, $r, $g, $b);
imagefilledrectangle($im, $x_pos, 0, 24, 30, $swatch);
}
// Set the content type header
header('Content-Type: image/png');
// Save the image
imagepng($im);
imagedestroy($im);
有谁知道我做错了什么或如何解决这个问题,以便从调色板下载所有 5 个色板?