| | #!/usr/bin/php |
---|
| | <?php |
---|
| | //error_reporting(0); |
---|
| | |
---|
| | $host = '52.43.252.153'; // websocket server |
---|
| | $port = 9001; |
---|
| | $local = "http://localhost"; // origin header |
---|
| |
---|
| | echo "[!] Please choose an image\n"; |
---|
| | exit(0); |
---|
| | }else{ |
---|
| | $imgStats = list($width, $height, $type, $attr) = getimagesize($filename); |
---|
| | echo "[i] Height: $imgStats[1]\n"; |
---|
| | echo "[i] Width: $imgStats[0]\n"; |
---|
| | echo "[?] checking dimensions\n"; |
---|
| | if($imgStats[0] <> 64 || $imgStats[1] <> 32) |
---|
| | die("[-] Image must be 64px Wide and 32px high"); |
---|
| | |
---|
| | $im = imagecreatefrompng($filename); |
---|
| |
---|
| | $arrC = array(); |
---|
| | //calculate percentage |
---|
| | $count++; |
---|
| | $percent = round(($count / 64) * 100, 2); |
---|
| | echo "[+] complete: $percent% \r"; |
---|
| | echo "[+] complete: $percent% \r"; // extra spaces are important sytalisticly |
---|
| | |
---|
| | for($y = 0; $y <= $imgStats[1]-1; $y++){ |
---|
| | $rgb = imagecolorat($im, $x, $y); |
---|
| | $newcol = color565($im, $rgb); |
---|
| |
---|
| | $g = (($green >> 2) & 0x3f) << 5; |
---|
| | $r = (($red >> 3) & 0x1f) << 11; |
---|
| | return "0x". strtoupper(dechex($r | $g | $b)); |
---|
| | } |
---|
| | |
---|
| | /*** |
---|
| | * functions below are for websocket interaction |
---|
| | */ |
---|
| | |
---|
| | // hibi10 decoding of data |
---|
| | function hybi10Decode($data) |
---|
| | { |
---|
| |
---|
| | } |
---|
| | |
---|
| | return $decodedData; |
---|
| | } |
---|
| | |
---|
| | // hibi10 encoding of data |
---|
| | function hybi10Encode($payload, $type = 'text', $masked = true) { |
---|
| | $frameHead = array(); |
---|
| | $frame = ''; |
---|
| |
---|
| | |