#!/usr/bin/env php $colorvalue) { $colorvalue = explode(',', $colorvalue); $colors[$i] = imagecolorallocatealpha($im, $colorvalue[0], $colorvalue[1], $colorvalue[2], $colorvalue[3]); if ($colors[$i] === false) echo "failed to allocate color $i\n"; } $x = $y = 0; foreach ($pixels as $i => $pixel) { $result = imagesetpixel($im, $x, $y, $colors[$pixel]); if ($result === false) echo "failed to set pixel at $x,$y\n"; $x++; if ($x >= $w) { $x = 0; $y++; } } imagecolortransparent($im, $colors[$pixels[0]]); imagepng($im, 'icon.png'); imagedestroy($im); ?>