Skip to content

Instantly share code, notes, and snippets.

@clone1018
Created August 10, 2016 05:25
Show Gist options
  • Save clone1018/c81886ae5157d71592d314c0f02e4aa4 to your computer and use it in GitHub Desktop.
Save clone1018/c81886ae5157d71592d314c0f02e4aa4 to your computer and use it in GitHub Desktop.
<?php
$lines = [
"1100000100011001000101010000111100000011100000110010001100001100000100001001000001001110011100000100001001000001010001001100000100001001000001010001101100000011100000110010001101001100000100011001000101010000011100000011000000110000001101011100000100011000110010001110001100000011100100111000001100001100000011010101000010001100001000110001101010011100100001010",
"1100000011010001000010001100011100000011001001000011001101111100000100011000111000001100111100000011011100110100001110001100000011011101000110001101001100000011011100110001001110011100000100000101000001010000011100000011001001000011001110001100000011000101000110001101101100000011010000110111010000111100000011010101000001001110001000100010000100100000100001010",
"1100000011000000110111010001101100010011010100110100001100011100000011100000110101010001001100000100010100110101010001001100000011001100110101010001001100010100001100110100001100011100010011010100110111010001101100000011010100110000001100001100000011010000111001010001001100000011000100110010001100101100010011000101000100001110001000100001110010100001100001010",
"110000001100100011011100111001110000001110010011000100111001110000001101000100000101000001110000001110000011000000110000110000001100010100010100111001110000001100110011000000111000110000001100110100011000110001110000010001010100010001000011110000010000110100001000110011110000001101100011000000110010110000010001000100010100111001110000001100000011100000001010",
"110000001100010011010100110011110000001101100011100100110000110000010000100100011000110000110000010000110100000100110001110000001100000011001001000010110000010001000011000000110011110000001110010100001100111000110000001110000011011000110110110000010001000100011000110111110000010001010100011000111001110000010000110011001000110001110000001100100011000000001010",
"11000101000110010001000011011111000101000110001101110011100111000100110101001110000011001011000100110010001101010011001011000000111000001100000011011011000101000010001101000100001011000101000110010000100011011111000100110000001101010011000011000000110101001100110011001011000000111001010000010011100111000100111000001101110011000011000101000110010001010100011000001010",
"1100000011001101000001001100001100000100000100110100001100111100000100000101000110010001101100000011011100111001001100111100000011011000110101001110001100000011000000110000010000111100000100011001000101001101001100000011100000110010001100011100000100001001000001001101001100000100001001000001001110001100000100001001000001010000011100000011100000110010010001101000110010001010100010000001010",
"110000010000100011011001000001110000010000100100010000110100110000001101000011100100110110110000001100110011001000110100110000010000010011001001000110110000001100110100001100110011110000001101110011100001000101110000001101110011001000110011110000001101100011001100110100110000001100000100001000111001110000001100100011100000110111110000010001010100011001000001110001001101110011001000001010",
"1100010100001000110101010001011100010011011101000110001110011100000011100000110011010001001100000011000100110110001100001100010100001001000110010001011100010100010000110001001101001100000011100100110101001101101100000011001100110001001110001100000011010101000110001100011100000011011001000100001101111100000011000101000010010000111100000100001100110010001101001100010011100001000011010001100010000000001010"
];
$padded = [
"1100000100011001000101010000111100000011100000110010001100001100000100001001000001001110011100000100001001000001010001001100000100001001000001010001101100000011100000110010001101001100000100011001000101010000011100000011000000110000001101011100000100011000110010001110001100000011100100111000001100001100000011010101000010001100001000110001101010011100100001010000000000000000000000000000000000000000000000",
"1100000011010001000010001100011100000011001001000011001101111100000100011000111000001100111100000011011100110100001110001100000011011101000110001101001100000011011100110001001110011100000100000101000001010000011100000011001001000011001110001100000011000101000110001101101100000011010000110111010000111100000011010101000001001110001000100010000100100000100001010000000000000000000000000000000000000000000000",
"1100000011000000110111010001101100010011010100110100001100011100000011100000110101010001001100000100010100110101010001001100000011001100110101010001001100010100001100110100001100011100010011010100110111010001101100000011010100110000001100001100000011010000111001010001001100000011000100110010001100101100010011000101000100001110001000100001110010100001100001010000000000000000000000000000000000000000000000",
"1100000011001000110111001110011100000011100100110001001110011100000011010001000001010000011100000011100000110000001100001100000011000101000101001110011100000011001100110000001110001100000011001101000110001100011100000100010101000100010000111100000100001101000010001100111100000011011000110000001100101100000100010001000101001110011100000011000000111000000010100000000000000000000000000000000000000000000000",
"1100000011000100110101001100111100000011011000111001001100001100000100001001000110001100001100000100001101000001001100011100000011000000110010010000101100000100010000110000001100111100000011100101000011001110001100000011100000110110001101101100000100010001000110001101111100000100010101000110001110011100000100001100110010001100011100000011001000110000000010100000000000000000000000000000000000000000000000",
"1100010100011001000100001101111100010100011000110111001110011100010011010100111000001100101100010011001000110101001100101100000011100000110000001101101100010100001000110100010000101100010100011001000010001101111100010011000000110101001100001100000011010100110011001100101100000011100101000001001110011100010011100000110111001100001100010100011001000101010001100000101000000000000000000000000000000000000000",
"1100000011001101000001001100001100000100000100110100001100111100000100000101000110010001101100000011011100111001001100111100000011011000110101001110001100000011000000110000010000111100000100011001000101001101001100000011100000110010001100011100000100001001000001001101001100000100001001000001001110001100000100001001000001010000011100000011100000110010010001101000110010001010100010000001010000000000000000",
"1100000100001000110110010000011100000100001001000100001101001100000011010000111001001101101100000011001100110010001101001100000100000100110010010001101100000011001101000011001100111100000011011100111000010001011100000011011100110010001100111100000011011000110011001101001100000011000001000010001110011100000011001000111000001101111100000100010101000110010000011100010011011100110010000010100000000000000000",
"1100010100001000110101010001011100010011011101000110001110011100000011100000110011010001001100000011000100110110001100001100010100001001000110010001011100010100010000110001001101001100000011100100110101001101101100000011001100110001001110001100000011010101000110001100011100000011011001000100001101111100000011000101000010010000111100000100001100110010001101001100010011100001000011010001100010000000001010"
];
//header("Content-Type: image/png");
foreach($lines as $line) {
$sqrt = ceil(sqrt(strlen($line)));
$line = str_pad($line, 441, 1, STR_PAD_RIGHT);
$image = imagecreate($sqrt,$sqrt);
$white = imagecolorallocate($image, 255,255,255);
$black = imagecolorallocate($image, 0, 0, 0);
$y = 0;
$x = 0;
for($i = 0; $i !== strlen($line); $i++) {
if($x / $sqrt == 1) { $x = 0; $y++; }
//echo $line[$i];
//echho "$x, $y<br>";
//echo "$x , $y <br>";
if($line[$i] == "0") {
$color = $black;
} else {
$color = $white;
}
imagesetpixel($image, $x, $y, $color);
$x++;
}
ob_start();
imagepng($image);
$pngData = ob_get_contents();
ob_end_clean();
echo "<img src='data: image/png;base64,".base64_encode($pngData)."'><br><br>".PHP_EOL;
imagedestroy($image);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment