body{margin:0;padding:0;} #canvas{width:{$scale}px;height:{$scale}px;margin:0;"; $im = imagecreatefromstring($data); $w = imagesx($im); $h = imagesy($im); $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); for ($x = 0; $x < $w; $x++) { for ($y = 0; $y < $h; $y++) { $rgb = imagecolorat($im, $x, $y); $color = imagecolorsforindex($im, $rgb); $color = rgb2hex($color); if ($x === 0 && $y === 0) { $html .= "background:$color; box-shadow:"; } else { $x1 = $scale * $x; $y1 = $scale * $y; $html .= "{$x1}px {$y1}px 0 $color,"; } } } $html = trim($html, ','); $html .= ";}
"; file_put_contents($argv[3], $html);