Okay, I’m using the following code as an API which should echo a JSON table with each pixel’s RGB value inside Color3.new(R, G, B).
<?php
if (array_key_exists('Image',$_GET)) {
$Image = $_GET["Image"];
$File = file_get_contents($Image);
$Colors = array();
list($width, $height) = getimagesize($File);
function AddToArray($X, $Y){
$rgb = imagecolorat($File, $X, $Y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
$Colors[] = "Color3.new(" + $r + ", " + $g + ", " + $b + ")";
}
$IX = 0;
$IY = 0;
while($IX <= $width and $IY <= $height){
AddToArray($IX, $IY);
$IX = $IX + 1;
$IY = $IY + 1;
}
echo json_encode($Colors);
}
?>
For some reason, it echoes an empty table. Could someone please help me by explaining what im doing wrong. Im a beginner at PHP. Thanks.